即使更改路径变量后也找不到命令

发布于 2024-11-08 13:22:17 字数 1092 浏览 0 评论 0原文

使用 Heroku 进行部署,同时通过 Michael Hartl 在 Ubuntu 11.04 Natty Narwhal 上编写的 Ruby On Rails 教程学习 Rails。我使用它安装了它

sudo gem install heroku

,并且命令似乎在终端中的该会话中运行良好。下次上班时,我尝试了命令“heroku open”,并被告知“heroku:命令未找到”。在这里查看类似问题的一些答案,似乎答案是运行,

gem enviroment

它返回以下内容:

RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
 - /var/lib/gems/1.8
 - /home/richard/.gem/ruby/1.8
- GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
- REMOTE SOURCES:
 - http://rubygems.org/

然后我运行

$ export PATH=$PATH:/var/lib/gems/1.8/bin

,它似乎解决了问题。然而,下次我尝试在终端中运行heroku时,我再次被告知“命令未找到”!运行“export PATH=$PATH”命令似乎每次都能解决问题,但我宁愿不必每次想使用 heroku 时都运行此命令。有没有永久解决问题的办法?

Using heroku for deployment while learning Rails with the Ruby On Rails tutorial by Michael Hartl, on Ubuntu 11.04 Natty Narwhal. I installed it using

sudo gem install heroku

and the commands seemed to run fine for that session in the terminal. The next time I went to work, I tried the command "heroku open" and I was told "heroku: command not found". Looking at some of the answers to similar problems here, it seemed the answer was to run

gem enviroment

which returned the following:

RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
 - /var/lib/gems/1.8
 - /home/richard/.gem/ruby/1.8
- GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
- REMOTE SOURCES:
 - http://rubygems.org/

I then ran

$ export PATH=$PATH:/var/lib/gems/1.8/bin

which seemed to fix the problem. However, the next time I tried to run heroku in the terminal, I was told "command not found" again! Running the "export PATH=$PATH" command seems to fix the problem every time, but I would rather I didn't have to run this command everytime I want to use heroku. Is there any permanent solution to the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不知在何时 2024-11-15 13:22:17

如果您使用 bash 作为 shell,则将该导出行添加到主目录中的 .bash_profile 中。 zsh 的等效项是 .zshrc,其他 shell 都有自己的文件,可以为每个 shell 会话自动加载。

If you're using bash as your shell, then add that export line to .bash_profile in your home directory. The equivalent for zsh is .zshrc, and other shells have their own files to automatically load for every shell session.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文