yonaskolb / Mint

A package manager that installs and runs executable Swift packages
MIT License
2.26k stars 122 forks source link

The mint command can not used in Xcode Run script phase (Mac 11.1 Xcode 12.4 ) #201

Open sunnyweekday opened 3 years ago

sunnyweekday commented 3 years ago

Hard ware: MacBook Pro 13 M1 Chip System Version: Mac OS 11.1 Xcode version:12.4

It was build fail when add "mint run swiftlint" script by Xcode Run script phase. The erros msg is:

Script-CC67A95425CFAF5700F12F11.sh: line 3: mint: command not found Command PhaseScriptExecution failed with a nonzero exit code

The demo project is attached.

BigWord.zip

danramteke commented 3 years ago

You could try the absolute path to mint to see if it's a $PATH issue? (run which mint to get the path). I have successfully run mint in build scripts.

mironal commented 3 years ago

It seems that the cause is that $PATH does not contain /opt/homebrew/bin in Xcode's Run Script.

I added the following code before running mint.

## begin
if [ `uname -m` == 'arm64' ] && [ -d /opt/homebrew/bin/ ]; then
  export PATH=/opt/homebrew/bin:$PATH
fi
## end

mint run swiftlint

Then the "mint: command not found" error no longer occurs.

However, I still get the error 🌱 swiftlint package not found and I can't execute the command with mint.

mime29 commented 2 years ago

Did you find a solution to this problem?

sunnyweekday commented 2 years ago

I resolved this by use the follow script : export PATH="/opt/homebrew/bin/:$PATH" mint run swiftlint

mime29 commented 2 years ago

Ok, I used your approach, it works. I just made a small change usingxcrun --sdk macosx mint to start Mint

mime29 commented 2 years ago

Is there a way to set the PATH system-wide ? I don't understand why we need to update the PATH during the script phase. For example my .zshrc already has the /opt/homebrew/bin/ PATH in the $PATH variable but still... Xcode throws this command not found error.

babacros commented 2 years ago

I had the same problem. After using another install method other than homebrew, everything works great. Lets try:

$ git clone https://github.com/yonaskolb/Mint.git
$ cd Mint
$ make
yukai18 commented 1 year ago

For those who wants to continue using mint from homebrew, you can symlink your brew's mint to /usr/local/bin/mint, make sure there is no existing mint folder in /usr/local/bin.

sudo ln -s /opt/homebrew/bin/mint /usr/local/bin/mint

source: https://stackoverflow.com/a/71674601

bystritskiy commented 1 year ago

For those who wants to continue using mint from homebrew, you can symlink your brew's mint to /usr/local/bin/mint, make sure there is no existing mint folder in /usr/local/bin.

sudo ln -s /opt/homebrew/bin/mint /usr/local/bin/mint

source: https://stackoverflow.com/a/71674601

Thanks! It's works!