I recently upgraded to Ubuntu 9.04 and I have issues using gems. I installed Ruby, Rubygems and Rails using apt-get. The rails
command does work.
我最近升级到Ubuntu 9.04,在使用gems时遇到了问题。我使用apt-get安装了Ruby、Rubygems和Rails。rails命令可以工作。
I then installed capistrano and other gems, such as heroku. In order to do that, I used the command:
然后我安装了capistrano和其他宝石,比如heroku。为了做到这一点,我使用了以下命令:
sudo gem install XXX
When I want to use the cap
command it does not work:
当我想使用cap命令时,它不起作用:
bash: cap: command not found
It is the same with the other gem commands.
它与其他gem命令是一样的。
Do I have something particular to do so that the gem commands work?
我有什么特别的事情要做,以使gem命令工作?
5 个解决方案
#1
138
Where are my Gems?
You can find where your gems are stored using the gem environment
command. For example:
您可以使用gem环境命令找到您的gem存储在哪里。例如:
chris@chris-laptop:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.2
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/chris/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
If you look at the "GEM PATHS:" section you can see that gems can be stored in two places on my laptop: /usr/lib/ruby/gems/1.8
or in the .gem
directory in my home dir.
如果您查看“GEM路径:”一节,您可以看到gems可以存储在我的笔记本上的两个位置:/usr/lib/ruby/gems/1.8,或者在我的home dir中的. GEM目录中。
You can also see that executables are stored in EXECUTABLE DIRECTORY which in this case is /usr/bin
.
您还可以看到可执行文件存储在可执行目录中,在本例中是/usr/ bin。
Because /usr/bin
is in my path this lets me run cap
, merb
, rails
etc.
因为/usr/bin在我的路径中这让我运行cap, merb, rails等。
Updating your PATH
If for some reason your EXECUTABLE DIRECTORY isn't on your path (for example if it is /var/lib/gems/1.8/bin) then you need to update your PATH variable.
如果由于某种原因,可执行目录不在路径上(例如,如果它是/var/lib/gems/1.8 bin),那么需要更新路径变量。
Assuming that you are using the bash shell. You can do this quickly for the current session by typing the following at the shell prompt; let's pretend that you want to add /var/lib/gems/1.8/bin
to the path:
假设您正在使用bash shell。通过在shell提示符下输入以下内容,可以快速完成当前会话;假设您想要在路径中添加/var/lib/gems/1.8/bin:
export PATH=$PATH:/var/lib/gems/1.8/bin
and press return. That appends the new directory to the end of the current path. Note the colon between $PATH
and /var/lib/gems/1.8/bin
并按返回。将新目录附加到当前路径的末尾。注意$PATH和/var/lib/gems/1.8/bin之间的冒号
To set the value for all sessions you will need to edit either your .profile
or .bashrc
file and add the same line to the end of the file. I usually edit my .bashrc
file for no reason other than that's what I've always done. When finished, save the file and then refresh your environment by typing:
要设置所有会话的值,需要编辑.profile或.bashrc文件,并在文件末尾添加相同的行。我通常编辑我的。bashrc文件,没有别的原因,除非我一直这样做。完成后,保存文件,然后输入:
bash
at the shell prompt. That will cause the .bashrc
to get reread.
在shell提示符。这会导致。bashrc重新读取。
At any point you can check the current value of $PATH
by typing
在任何时候,您都可以通过输入来检查$PATH的当前值
echo $PATH
at the shell prompt.
在shell提示符。
Here's a sample from one of my own servers, where my username is "chris" and the machine name is "chris-laptop":
这是我自己服务器的一个示例,我的用户名是“chris”,机器名是“chris-laptop”:
chris@chris-laptop:~$
chris@chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
chris@chris-laptop:~$
chris@chris-laptop:~$ export PATH=$PATH:/var/lib/gems/1.8/bin
chris@chris-laptop:~$
chris@chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin
chris@chris-laptop:~$
My Gem won't load!
"Ruby gems won't load even though installed" highlights a common problem using multiple different versions of Ruby; Sometimes the Gem environment and Gem path get out of sync:
“Ruby gems不会加载,即使安装”突出了使用多个不同版本的Ruby的常见问题;有时创业板环境和创业板路径不同步:
rb(main):003:0> Gem.path
=> ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
irb(main):004:0> exit
Any Ruby process here is looking only in one place for its Gems.
这里的任何Ruby进程都只在一个地方寻找它的精华。
:~/$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/ruby1.9/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/ruby1.9/bin/ruby1.9
- EXECUTABLE DIRECTORY: /opt/ruby1.9/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
- /home/mark/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Look carefully at the output of gem environment:
仔细查看gem环境的输出:
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
This isn't the same path as returned by Gem.path:
这与Gem.path返回的路径不同。
["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
It's hard to say what exactly caused lib/ruby
to change to lib/ruby1.9
but most likely the developer was working with multiple Ruby versions. A quick mv
or ln
will solve the problem.
很难说到底是什么原因导致lib/ruby更改为lib/ruby1.9,但最有可能的是开发人员正在使用多个ruby版本。一个快速的mv或ln将解决这个问题。
If you do need to work with multiple Ruby versions then you really should be using rvm.
如果您确实需要使用多个Ruby版本,那么您确实应该使用rvm。
#2
5
As noted by @Chris you need to add the gems environment to your path. You can do this by:
正如@Chris指出的,您需要将gems环境添加到路径中。你可以这样做:
echo 'export PATH=$PATH:/var/lib/gems/1.8/bin' | tee --append ~/.bashrc
#3
3
The folder in which gems are stored must be on your PATH, for example mine is:
存储宝石的文件夹必须在您的路径上,例如我的文件夹是:
/home/victor/.gem/ruby/1.8/bin
/home/victor/.gem/ruby/1.8/bin
Check your path by typing
通过输入检查路径
echo $PATH
#4
1
It seens that when installing rubygems, now in ubuntu 9.04, I have this problem. I noticed that in "gem environment" the executable directory is "/var/lib/gems/1.8/bin", instead of "/usr/bin"... This is a problem with rubygems or with ubuntu 9.04??
在ubuntu 9.04中安装rubygems时,我遇到了这个问题。我注意到在“gem环境”中,可执行目录是“/var/lib/gems/1.8/bin”,而不是“/usr/bin”…这是rubygems还是ubuntu 9.04的问题?
The solution that I encountered is to add "/var/lib/gems/1.8/bin" to my $PATH doing this: export PATH=$PATH:/var/lib/gems/1.8/bin But it don't is saved... how can I save my path?
我遇到的解决方案是将“/var/lib/gems/1.8/bin”添加到我的$路径中,这样做:export PATH=$PATH:/var/lib/gems/1.8/bin,但它没有保存…我该如何拯救我的路?
Thanks...
谢谢……
Resolvi: coloquei o export PATH=$PATH:/var/lib/gems/1.8/bin no ~/.bashrc! =]
代码输出路径=$PATH:/var/lib/gems/1.8/bin no ~/.bashrc!=)
#5
0
mkmf is part of the ruby1.9.1-dev package. This package contains the header files needed for extension libraries for Ruby 1.9.1. You need to install the ruby1.9.1-dev package by doing:
mkmf是ruby1.9.1-dev包的一部分。这个包包含Ruby 1.9.1扩展库所需的头文件。您需要通过以下步骤安装ruby1.9.1-dev包:
sudo apt-get install ruby1.9.1-dev
sudo apt-get安装ruby1.9.1-dev
#1
138
Where are my Gems?
You can find where your gems are stored using the gem environment
command. For example:
您可以使用gem环境命令找到您的gem存储在哪里。例如:
chris@chris-laptop:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.2
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/chris/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
If you look at the "GEM PATHS:" section you can see that gems can be stored in two places on my laptop: /usr/lib/ruby/gems/1.8
or in the .gem
directory in my home dir.
如果您查看“GEM路径:”一节,您可以看到gems可以存储在我的笔记本上的两个位置:/usr/lib/ruby/gems/1.8,或者在我的home dir中的. GEM目录中。
You can also see that executables are stored in EXECUTABLE DIRECTORY which in this case is /usr/bin
.
您还可以看到可执行文件存储在可执行目录中,在本例中是/usr/ bin。
Because /usr/bin
is in my path this lets me run cap
, merb
, rails
etc.
因为/usr/bin在我的路径中这让我运行cap, merb, rails等。
Updating your PATH
If for some reason your EXECUTABLE DIRECTORY isn't on your path (for example if it is /var/lib/gems/1.8/bin) then you need to update your PATH variable.
如果由于某种原因,可执行目录不在路径上(例如,如果它是/var/lib/gems/1.8 bin),那么需要更新路径变量。
Assuming that you are using the bash shell. You can do this quickly for the current session by typing the following at the shell prompt; let's pretend that you want to add /var/lib/gems/1.8/bin
to the path:
假设您正在使用bash shell。通过在shell提示符下输入以下内容,可以快速完成当前会话;假设您想要在路径中添加/var/lib/gems/1.8/bin:
export PATH=$PATH:/var/lib/gems/1.8/bin
and press return. That appends the new directory to the end of the current path. Note the colon between $PATH
and /var/lib/gems/1.8/bin
并按返回。将新目录附加到当前路径的末尾。注意$PATH和/var/lib/gems/1.8/bin之间的冒号
To set the value for all sessions you will need to edit either your .profile
or .bashrc
file and add the same line to the end of the file. I usually edit my .bashrc
file for no reason other than that's what I've always done. When finished, save the file and then refresh your environment by typing:
要设置所有会话的值,需要编辑.profile或.bashrc文件,并在文件末尾添加相同的行。我通常编辑我的。bashrc文件,没有别的原因,除非我一直这样做。完成后,保存文件,然后输入:
bash
at the shell prompt. That will cause the .bashrc
to get reread.
在shell提示符。这会导致。bashrc重新读取。
At any point you can check the current value of $PATH
by typing
在任何时候,您都可以通过输入来检查$PATH的当前值
echo $PATH
at the shell prompt.
在shell提示符。
Here's a sample from one of my own servers, where my username is "chris" and the machine name is "chris-laptop":
这是我自己服务器的一个示例,我的用户名是“chris”,机器名是“chris-laptop”:
chris@chris-laptop:~$
chris@chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
chris@chris-laptop:~$
chris@chris-laptop:~$ export PATH=$PATH:/var/lib/gems/1.8/bin
chris@chris-laptop:~$
chris@chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin
chris@chris-laptop:~$
My Gem won't load!
"Ruby gems won't load even though installed" highlights a common problem using multiple different versions of Ruby; Sometimes the Gem environment and Gem path get out of sync:
“Ruby gems不会加载,即使安装”突出了使用多个不同版本的Ruby的常见问题;有时创业板环境和创业板路径不同步:
rb(main):003:0> Gem.path
=> ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
irb(main):004:0> exit
Any Ruby process here is looking only in one place for its Gems.
这里的任何Ruby进程都只在一个地方寻找它的精华。
:~/$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/ruby1.9/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/ruby1.9/bin/ruby1.9
- EXECUTABLE DIRECTORY: /opt/ruby1.9/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
- /home/mark/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Look carefully at the output of gem environment:
仔细查看gem环境的输出:
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
This isn't the same path as returned by Gem.path:
这与Gem.path返回的路径不同。
["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
It's hard to say what exactly caused lib/ruby
to change to lib/ruby1.9
but most likely the developer was working with multiple Ruby versions. A quick mv
or ln
will solve the problem.
很难说到底是什么原因导致lib/ruby更改为lib/ruby1.9,但最有可能的是开发人员正在使用多个ruby版本。一个快速的mv或ln将解决这个问题。
If you do need to work with multiple Ruby versions then you really should be using rvm.
如果您确实需要使用多个Ruby版本,那么您确实应该使用rvm。
#2
5
As noted by @Chris you need to add the gems environment to your path. You can do this by:
正如@Chris指出的,您需要将gems环境添加到路径中。你可以这样做:
echo 'export PATH=$PATH:/var/lib/gems/1.8/bin' | tee --append ~/.bashrc
#3
3
The folder in which gems are stored must be on your PATH, for example mine is:
存储宝石的文件夹必须在您的路径上,例如我的文件夹是:
/home/victor/.gem/ruby/1.8/bin
/home/victor/.gem/ruby/1.8/bin
Check your path by typing
通过输入检查路径
echo $PATH
#4
1
It seens that when installing rubygems, now in ubuntu 9.04, I have this problem. I noticed that in "gem environment" the executable directory is "/var/lib/gems/1.8/bin", instead of "/usr/bin"... This is a problem with rubygems or with ubuntu 9.04??
在ubuntu 9.04中安装rubygems时,我遇到了这个问题。我注意到在“gem环境”中,可执行目录是“/var/lib/gems/1.8/bin”,而不是“/usr/bin”…这是rubygems还是ubuntu 9.04的问题?
The solution that I encountered is to add "/var/lib/gems/1.8/bin" to my $PATH doing this: export PATH=$PATH:/var/lib/gems/1.8/bin But it don't is saved... how can I save my path?
我遇到的解决方案是将“/var/lib/gems/1.8/bin”添加到我的$路径中,这样做:export PATH=$PATH:/var/lib/gems/1.8/bin,但它没有保存…我该如何拯救我的路?
Thanks...
谢谢……
Resolvi: coloquei o export PATH=$PATH:/var/lib/gems/1.8/bin no ~/.bashrc! =]
代码输出路径=$PATH:/var/lib/gems/1.8/bin no ~/.bashrc!=)
#5
0
mkmf is part of the ruby1.9.1-dev package. This package contains the header files needed for extension libraries for Ruby 1.9.1. You need to install the ruby1.9.1-dev package by doing:
mkmf是ruby1.9.1-dev包的一部分。这个包包含Ruby 1.9.1扩展库所需的头文件。您需要通过以下步骤安装ruby1.9.1-dev包:
sudo apt-get install ruby1.9.1-dev
sudo apt-get安装ruby1.9.1-dev