0

安装我的 react-native 项目时出现此错误-

/Users/username/.rvm/scripts/rvm: line 12: uname: command not found
/Users/username/.rvm/scripts/rvm: line 29: ps: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: readlink: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: dirname: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: cd: : No such file or directory Command PhaseScriptExecution
failed with a nonzero exit code

这是我的~/.zshrc文件-

export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

环境 -

❯ echo $PATH
/Users/<username>/.rvm/gems/ruby-3.0.0/bin:/Users/<username>/.rvm/gems/ruby-3.0.0@global/bin:/Users/<username>/.rvm/rubies/ruby3.0.0/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/<username>/Library/Android/sdk/emulator:/Users/<username>/Library/Android/sdk/tools:/Users/<username>/Library/Android/sdk/platform-tools:/Users/<username>/.rvm/bin
4

1 回答 1

0

解决方案#1

日志中的以下错误消息表明命令行工具无法理解RVM 脚本中的unameps引用。

/Users/username/.rvm/scripts/rvm: line 12: uname: command not found

我很好奇uname的下落所以我做了这个——

> which uname
/usr/local/opt/coreutils/libexec/gnubin/uname

如上所示,此路径已添加到我的 .zshrc 文件中,但仍未解决问题。

打开 RVM 脚本后,我知道它没有使用 zsh shell,而是使用 bash shell,所以我在最后的 .bash_profile 文件中添加了这个 uname 路径 -

export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH

它开始工作了。

解决方案 #2

其他替代解决方案可以是将 rvm 脚本的 shell 从 zsh 更改为 bash。只需更改脚本的第一行

#!/usr/bin/<<shell name - bash/zsh>>
于 2021-12-24T17:20:53.480 回答