安装 RVM 后,Rails Server 或 Git 无法工作

发布于 2024-12-21 16:08:44 字数 3687 浏览 0 评论 0原文

我再次破坏了它,不幸的是我不知道为什么......

首先是问题

使用在RVM安装期间创建的.bash_profile找不到Git。在 .profile 中添加回从 mac 端口导出的旧路径会通过将 ruby​​ 恢复到 1.8.7 来破坏 Rails 服务器,

我想我确定

/opt/local/bin:
/opt/local/sbin:

.bash_profile 中的两个目录code> 将使 Git 正常工作,但会破坏新的 RVM ruby​​ 版本。

解决方案

所以这里是解决方案: 我使用的是 Mac Ports Git 版本。这就是为什么它不会运行,除非 Mac Ports 目录是路径的一部分。当 Mac Ports 目录在 RVM 之后获取时,Mac Ports Ruby 版本似乎优先于 RVM 版本。

这将破坏

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

这将工作:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

感谢@third为我指明了正确的方向:)

我如何破坏它

杂耍Ruby和Rails版本为了与我正在学习这两个版本的教程保持同步,RVM 这个名称不断出现,作为一种更方便地管理这些版本的工具。

我安装了它并让它工作

ruby -v
$ ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

rails -v
$ Rails 3.1.3

在这个过程中我的 .profile 开始失败,但我认为这是因为在RVM 安装。我原以为会遇到麻烦,但到目前为止一切都很好,一切正常,包括 Rails 服务器。

rails s
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-19 10:16:15] INFO  WEBrick 1.3.1
[2011-12-19 10:16:15] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-12-19 10:16:15] INFO  WEBrick::HTTPServer#start: pid=53018 port=3000

然后我想提交到Git,但是突然不行了

git
-bash: git: command not found

所以我对比了.profile.bash_profile发现Mac Ports添加了一行最初安装 ruby​​、rails 和 git 时将代码添加到 .profile 中(当然我 100% 都使用了 MacPorts)

##
# Your previous /Users/username/.profile file was backed up as /Users/username/.profile.macports-saved_2011-10-19_at_08:48:41
##

# MacPorts Installer addition on 2011-10-19_at_08:48:41: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

如果我使用此设置查询 ruby​​ 版本,我会得到:

ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]

所以我的新手猜测是我坏了过程中的路径变量安装 RVM。如果我将该行添加到 .bash_profile git 会再次工作,但 Rails 服务器不会。注意 ruby​​ 版本不匹配。:

rails s
/Users/username/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]

Abort trap

使用 Mac Ports PATH 导出时我的 $PATH 的内容是:

echo $PATH
/opt/local/bin:
/opt/local/sbin:
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:

另一方面,使用 .bash_profile 这是 $PATH 内容:

echo $PATH
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:

看起来非常相似,除了这两个目录:

/opt/local/bin:
/opt/local/sbin:

所以我的猜测是,这就是它崩溃的地方......但我不知道该怎么办。

我对所有这些开发仍然很陌生,Apple 计算机、Unix、Ruby、Rails 的东西:(

非常感谢任何帮助。

谢谢 TIM

I broke it again and unfortunately I am not sure why...

Problem first

Using the .bash_profile that was created during RVM installation Git cannot be found. Adding back the old path exports from mac ports in the .profile breaks the rails server by reverting ruby back to 1.8.7

I think I identified

/opt/local/bin:
/opt/local/sbin:

to be the two directories in the .bash_profile that will make Git work but break the new RVM ruby verison.

Solution

So here the solution:
I am using a Mac Ports Git version. Thats why it won't run, unless the Mac Ports directories are part of the path. When the Mac Ports directories are sourced after RVM the Mac Ports Ruby Version seem to take precedence over the RVM version.

This will break:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

This will work:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

Thanks @three for pointing me in the right direction :)

How I broke it

Juggeling Ruby and Rails versions around to be in sync with the tutorials I am doing to learn the two, the name RVM kept popping up as a tool to manage those versions more conveniently.

I installed it and and got it to work

ruby -v
$ ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

rails -v
$ Rails 3.1.3

In the process my .profile started failing, but I think that is because of the precedence of the .bash_profile that was created during the RVM installation. I was expecting trouble but all good so far and everything working, including the rails server.

rails s
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-19 10:16:15] INFO  WEBrick 1.3.1
[2011-12-19 10:16:15] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-12-19 10:16:15] INFO  WEBrick::HTTPServer#start: pid=53018 port=3000

Then I wanted to commit to Git, but that all of a sudden doesn't work anymore

git
-bash: git: command not found

So I compared the .profile and .bash_profile found that Mac Ports added a line of code to the .profile when initially installing ruby, rails and git (sure 100% I used MacPorts for all three)

##
# Your previous /Users/username/.profile file was backed up as /Users/username/.profile.macports-saved_2011-10-19_at_08:48:41
##

# MacPorts Installer addition on 2011-10-19_at_08:48:41: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

If I query the ruby version with this setting I get:

ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]

So my newbie guess is I broke the path variable in the process of installing RVM. If I add the line to the .bash_profile git works again, but the rails server doesn't. Notice the ruby version missmatch.:

rails s
/Users/username/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]

Abort trap

The contents of my $PATH when using the Mac Ports PATH exports is:

echo $PATH
/opt/local/bin:
/opt/local/sbin:
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:

On the other hand using the .bash_profile as is this is the $PATH contents:

echo $PATH
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:

Looks pretty similar, except for those two directories:

/opt/local/bin:
/opt/local/sbin:

So my guess is, thats where it breaks... But I have no idea what to do about it.

I am still so new to all of this development, Apple Computers, Unix, Ruby, Rails Stuff :(

Any help is greatly appreciated.

Thanks
TIM

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

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

发布评论

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

评论(2

轻拂→两袖风尘 2024-12-28 16:08:44

将 RVM 行放在 macports 的导出路径之后,以便 ruby​​ 的 rvm 二进制文件优先。

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

还可以考虑使用 homebrew 而不是 macports,这是维护 *nix 工具的更灵活的版本。

put the RVM line after the export PATH for macports so that the rvm binaries for ruby will take precendence

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

Also consider using homebrew instead of macports which is the much slicker version of maintaining *nix tools.

捶死心动 2024-12-28 16:08:44

将此行插入到 .bash_profile:

source "$HOME/.profile"

在 RVM 添加内容之前。

insert this line to .bash_profile:

source "$HOME/.profile"

before RVM added contents.

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