使用“回形针" gem 和 Ruby on Rails 3 的问题 [英] Problem using the 'paperclip' gem and Ruby on Rails 3

查看:33
本文介绍了使用“回形针" gem 和 Ruby on Rails 3 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行Snow Leopard"v1.6.5 的 MacO 上使用 Ruby on Rails 3.

I am using Ruby on Rails 3 on a MacOs running 'Snow Leopard' v1.6.5.

我想使用回形针"宝石,所以我将它包含在我的 Gemfile 中,如下所示:

I want to use the 'paperclip' gem so I included it in my Gemfile like this:

gem 'paperclip', "~> 2.3"

然后,在终端中我运行命令:

Then, in the Terminal I run the command:

sudo bundle install

结果是:

...
Using paperclip (2.3.8) 
Using thor (0.14.6) 
Using railties (3.0.1) 
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

这意味着安装了'paperclip v2.3.8'.

that means that 'paperclip v2.3.8' is installed.

然后我从系统偏好设置/共享/面板"重新启动了apache"

Then I restarted 'apache' from the 'System Preferences/Sharing/ panel

使用我的 RoR 应用程序并在网站中本地导航时,我意识到出了点问题.因此,要查看控制台消息"中的日志,我发现了以下内容:

Using my RoR application and navigating locally in the website, I realized that something was wrong. So, going to see logs in the 'Console Messages', I found the following:

18/01/2011 16:50:52 org.apache.httpd[12972] [31mCould not find paperclip-2.3.8 in any of the sources[0m

什么意思?如何解决问题?

更新(重要!!!)

我正确地重新安装了 RVM,现在,运行命令 'rvm',我让它工作了...但 'paperclip' 还没有:在日志中我仍然有问题 'Could not find paperclip-2.3.8 在任何来源'.

I reinstalled correctly RVM and now, running the command 'rvm', I get it to work... but 'paperclip' doesn't yet: in logs I still have the problem 'Could not find paperclip-2.3.8 in any of the sources'.

注意:这次我使用了 bundle install 而不是 sudo bundle install

Notice: this time I used bundle install instead of sudo bundle install!

我发现在终端中运行命令rails server",我的 RoR3 应用程序与 URL http://0.0.0.0:3000 上的回形针"配合得很好.当我在 URL http://project.local 上使用来自Snow Leopard"的 apache 的基本安装时,它不会. 为什么会发生?!

I discovered that running the command 'rails server' in the Terminal, my RoR3 application works great with 'paperclip' on the URL http://0.0.0.0:3000. It doesn't when I use the basic installation of apache from 'Snow Leopard' on the URL http://project.local. Why does it happen?!

编辑(在回答中的请求之后)

rvm info 的输出是:

/usr/local/bin/rvm: line 73: /Users/<my_user_name>/.rvm/scripts/rvm: No such file or directory
...
<A lot of the same line>
...
/usr/local/bin/rvm: line 73: /Users/<my_user_name>/.rvm/scripts/rvm: No such file or directory
/usr/local/bin/rvm: fork: Resource temporarily unavailable
/usr/local/bin/rvm: fork: Resource temporarily unavailable

<小时>

附言我:我尝试使用 gem 'paperclip', '2.3.8' 而不是 gem 'paperclip', "~> 2.3",但它不起作用.


P.S. I: I tryed to use gem 'paperclip', '2.3.8' instead of gem 'paperclip', "~> 2.3", but it doesn't work.

附言II:我也在使用 MacPorts 并且我已经安装了 Image-Magick.

P.S. II: I am also using MacPorts and I have installed Image-Magick.

推荐答案

我得到:/usr/local/bin/rvm:第 73 行:/Users//.rvm/scripts/rvm

I get: "/usr/local/bin/rvm: line 73: /Users//.rvm/scripts/rvm

嗯,这很有趣.你不应该在 /usr/local/bin 中看到 rvm,所以有些东西搞砸了.请通过编辑将 rvm info 的输出添加到您的问题中.

Well, that is interesting. You should not see rvm in /usr/local/bin, so something is messed up. Please add the output of rvm info to your question by editing it.

除非您有非常特殊的需求,并且如果您知道,因为您要为多个用户管理一个主机,则永远不要将 sudo 与 rvm 或 rvm 控制一起使用宝石.sudo 或在安装 rvm 时以 root 身份运行导致的混合权限,将导致各种奇怪的行为.

Unless you have very special needs, and, if you did you'd know it because you'd be administering a host for multiple users, you should never use sudo with rvm or a rvm controlled gem. The mixed permissions caused by sudo, or by running as root as you install rvm, will cause all sorts of weird behavior.

如果您有混合/多个 rvm 版本,那么首先要做的就是清理老鼠窝并将其恢复到干净/稳定的状态.

If you have mixed/multiple rvm versions, then the first job is to clean out the rat's nest and return things to a clean/stable state.

然后,您可以安装当前版本的 rvm,并让它安装您的 Ruby.此外,使用 rvm get head 使 rvm 保持最新非常重要.作者每周更新几次,更新是透明的,但添加了错误修复和新功能.

Then, you can install a current version of rvm, and let it install your Rubies. Also, it is really important to keep rvm up to date using rvm get head. The author updates it several times a week, and the updates are transparent but add bug fixes and new features.

rvm info 显示bad brokage".

rvm info shows "bad brokage".

除了你的 ~/.rvm 路径之外,我们还需要弄清楚 rvm 的安装位置.在命令行输入:

We need to figure out where rvm is installed, besides your ~/.rvm path. At the command-line type:

locate rvm | grep -v /Users

特别是我们正在寻找 rvm shell 脚本的任何实例.例如,这是我安装的第二个版本,用于帮助 TextMate 与 rvm 配合使用:

In particular we're looking for any instances of the rvm shell script. For instance, this is a second version I have installed to help TextMate work with rvm:

/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby on Rails.tmbundle/Support/lib/rvm

请注意,它只是行尾的单词rvm".

Notice it's just the word "rvm" at the end of the line.

我创立:"

好的,这是个好消息.RVM 旨在从一个目录工作.您可以运行几个命令来清理 /usr/local 路径:

Ok, that's good news. RVM is designed to work from one directory. You can run a couple commands to clean up the /usr/local path:

下一部分将删除文件和目录,因此需要谨慎操作.如果您习惯使用命令行工作并了解典型的系统管理,则可以按原样执行以下操作:

This next part will delete files and directories so it needs to be done carefully. If you are comfortable working from the command-line and understand typical system administration, you can do these as they are:

sudo rm /_rvm
sudo rm /usr/bin/rvm-install
sudo rm /usr/local/bin/rvm-prompt
sudo rm /usr/local/bin/rvm-shell
sudo rm /usr/local/bin/rvmsudo 

sudo rm /usr/local/bin/rvm

sudo rm -rf /usr/local/rvm/

如果你想更加谨慎,你可以打开一个 Finder 窗口,然后执行 CMD+SHFT+G 打开一个转到文件夹"对话框.复制并粘贴上面命令行中的第一个 PATH,然后按回车键.Finder 将跳转到该目录.查找该文件 (_rvm).将其拖到垃圾箱.系统应提示您输入 sudo 密码.对每一个命令重复.这很好用,因为它让 Finder 使用它的一些智能来帮助保护你免受我愚蠢的错误.:-)

If you want to be more cautious, you can open a Finder window, then do CMD+SHFT+G to open a "Go to the folder" dialog. Copy and paste the first PATH in the command-lines above, and press return. The Finder will jump to that directory. Look for that file (_rvm). Drag it to the trash. The system should prompt you for your sudo password. Repeat for each one of the commands. This works nicely because it lets the Finder use some of its intelligence to help protect you from my stupid mistakes. :-)

这些东西被删除后,你的机器应该被部分清理.从命令行输入 echo $PATH 并查看是否列出了这些路径中的任何一个.如果是这样,打开你的~/.bashrc~/.bash_profile,找到你的 PATH 环境变量被修改的地方,并删除那个目录路径.

After those things are deleted your machine should be partly cleaned up. From the command-line type echo $PATH and see if any of those paths are listed. If so, open you ~/.bashrc or ~/.bash_profile, find where your PATH environment variable is modified, and remove that directory path.

然后,输入 ls -al ~/.rvm.如果您的家中有 .rvm 文件夹,那么您可以使用 rm -rf ~/.rvm 删除它.之后,检查您的 .bashrc 或 .bash_profile 中是否有任何不指向 ~/.rvm/Users/your_account_name/.rvm 的 rvm.删除它们,关闭终端窗口,然后重新打开它.

Then, type ls -al ~/.rvm. If you have a .rvm folder in your home, then you can delete it with rm -rf ~/.rvm. Following that, check your .bashrc or .bash_profile for anything with rvm that does NOT point to ~/.rvm or /Users/your_account_name/.rvm. Remove those, close your terminal window, then re-open it.

此时 rvm 应该从你的机器上移除.

At this point rvm should be removed from your machine.

这里已经很晚了,我整个周末都病了,所以我们明天会通过重新安装 RVM 和您的红宝石来解决这个问题,或者,如果您有信心,请自己尝试一下.请记住,您不必必须使用 sudo 来安装 RVM.它应该安装到您的主目录中,不会有任何抱怨.

It's late here, and I've been sick all weekend, so we'll pick it up tomorrow with reinstalling RVM and your Rubies, or, if you feel confident, give it a try yourself. Remember, you do NOT have to use sudo to install RVM. It should install into your home directory without any complaints.

此外,我认为我们还没有确定您正在运行的操作系统或 XCode 的版本.你可能想要 从他们的网站下载适用于您操作系统的 Apple 最新版本的 XCode.DVD 中 Snow Leopard 附带的版本存在一些错误,应尽快升级.如果您没有开发者帐户,请创建一个.他们是免费的.

Also, I don't think we've established what version of the OS, or of XCode you are running. You might want to download Apple's most recent version of XCode for your OS from their website. The version that came with Snow Leopard on the DVD has some bugs and should be upgraded ASAP. If you don't have a developer account then create one. They're free.

这篇关于使用“回形针" gem 和 Ruby on Rails 3 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆