简体   繁体   English

使用'paperclip'gem和Ruby on Rails 3的问题

[英]Problem using the 'paperclip' gem and Ruby on Rails 3

I am using Ruby on Rails 3 on a MacOs running 'Snow Leopard' v1.6.5. 我在运行'Snow Leopard'v1.6.5的MacO上使用Ruby on Rails 3。

I want to use the 'paperclip' gem so I included it in my Gemfile like this: 我想使用'paperclip'gem,所以我将它包含在我的Gemfile中,如下所示:

gem 'paperclip', "~> 2.3"

Then, in the Terminal I run the command: 然后,在终端I中运行命令:

sudo bundle install

The result is: 结果是:

...
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.

that means that 'paperclip v2.3.8' is installed. 这意味着安装了'paperclip v2.3.8'。

Then I restarted 'apache' from the 'System Preferences/Sharing/ panel 然后我从'系统偏好设置/共享/面板'重新启动'apache'

Using my RoR application and navigating locally in the website, I realized that something was wrong. 使用我的RoR应用程序并在网站本地导航,我意识到出了问题。 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

What means? 什么意思? How to resolve the problem? 如何解决问题?


UPDATE ( important ! ! ! ) 更新(重要!!!)

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 '. 我正确地重新安装了RVM,现在,运行命令'rvm',我让它工作......但'paperclip'还没有:在日志中我仍然有问题' Could not find paperclip-2.3.8 in any of the sources '。

Notice: this time I used bundle install instead of sudo bundle install ! 注意:这次我使用的是bundle install而不是sudo bundle install

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 . 我发现在终端中运行命令'rails server',我的RoR3应用程序在URL http://0.0.0.0:3000上使用'paperclip'非常有效。 It doesn't when I use the basic installation of apache from 'Snow Leopard' on the URL http://project.local . 当我在URL http://project.local上使用来自'Snow Leopard'的apache的基本安装时,它不会。 Why does it happen?! 为什么会这样?!


EDIT (after a request in an answer) 编辑(在回答请求后)

The output of rvm info is: 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

PS I: I tryed to use gem 'paperclip', '2.3.8' instead of gem 'paperclip', "~> 2.3" , but it doesn't work. PS I:我尝试使用gem 'paperclip', '2.3.8'而不是gem 'paperclip', "~> 2.3" ,但它不起作用。

PS II: I am also using MacPorts and I have installed Image-Magick . PS II:我也在使用MacPorts ,我已经安装了Image-Magick

I get: "/usr/local/bin/rvm: line 73: /Users//.rvm/scripts/rvm 我得到:“/ usr / local / bin / rvm:第73行:/Users//.rvm/scripts/rvm

Well, that is interesting. 嗯,这很有趣。 You should not see rvm in /usr/local/bin , so something is messed up. 你不应该在/usr/local/bin看到rvm,所以搞砸了。 Please add the output of rvm info to your question by editing it. 请通过编辑将rvm info的输出添加到您的问题中。

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. 除非你有非常特殊的需求,并且,如果你知道它,因为你要为多个用户管理主机,你绝不应该使用带有rvm或rvm控制的gem的sudo The mixed permissions caused by sudo , or by running as root as you install rvm, will cause all sorts of weird behavior. sudo引起的混合权限,或者在安装rvm时以root身份运行,将导致各种奇怪的行为。

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版本,那么第一个工作就是清理老鼠的巢并将东西恢复到干净/稳定的状态。

Then, you can install a current version of rvm, and let it install your Rubies. 然后,您可以安装当前版本的rvm,并让它安装您的Rubies。 Also, it is really important to keep rvm up to date using rvm get head . 此外,使用rvm get head保持rvm最新非常重要。 The author updates it several times a week, and the updates are transparent but add bug fixes and new features. 作者每周更新几次,更新是透明的,但添加了错误修复和新功能。


Edit: rvm info shows "bad brokage". 编辑: rvm info显示“糟糕的rvm info ”。

We need to figure out where rvm is installed, besides your ~/.rvm path. 除了你的~/.rvm路径之外,我们需要弄清楚rvm的安装~/.rvm At the command-line type: 在命令行类型:

locate rvm | grep -v /Users

In particular we're looking for any instances of the rvm shell script. 特别是我们正在寻找rvm shell脚本的任何实例。 For instance, this is a second version I have installed to help TextMate work with rvm: 例如,这是我安装的第二个版本,以帮助TextMate使用rvm:

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

Notice it's just the word " rvm " at the end of the line. 请注意,它只是行尾的“ rvm ”。


EDIT: "I founded:" 编辑:“我创立:”

Ok, that's good news. 好的,这是个好消息。 RVM is designed to work from one directory. RVM旨在从一个目录工作。 You can run a couple commands to clean up the /usr/local path: 您可以运行几个命令来清理/usr/local路径:

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/

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. 如果您想更加谨慎,可以打开Finder窗口,然后执行CMD+SHFT+G打开“转到文件夹”对话框。 Copy and paste the first PATH in the command-lines above, and press return. 将第一个PATH复制并粘贴到上面的命令行中,然后按Return键。 The Finder will jump to that directory. Finder将跳转到该目录。 Look for that file ( _rvm ). 查找该文件( _rvm )。 Drag it to the trash. 将其拖到垃圾箱。 The system should prompt you for your sudo password. 系统应提示您输入sudo密码。 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. 这很好用,因为它让Finder使用它的一些智能来帮助保护你免受我的愚蠢错误。 :-) :-)

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. 从命令行键入echo $PATH并查看是否列出了任何这些路径。 If so, open you ~/.bashrc or ~/.bash_profile , find where your PATH environment variable is modified, and remove that directory path. 如果是这样,打开~/.bashrc~/.bash_profile ,找到修改PATH环境变量的位置,并删除该目录路径。

Then, type ls -al ~/.rvm . 然后,键入ls -al ~/.rvm If you have a .rvm folder in your home, then you can delete it with rm -rf ~/.rvm . 如果您家中有.rvm文件夹,则可以使用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 . 接下来,检查.bashrc或.bash_profile以查找rvm不指向~/.rvm/Users/your_account_name/.rvm Remove those, close your terminal window, then re-open it. 删除它们,关闭终端窗口,然后重新打开它。

At this point rvm should be removed from your machine. 此时应从您的机器中删除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. 现在已经很晚了,我整个周末都病了,所以明天我们会重新安装RVM和你的红宝石,或者,如果你有信心,可以自己尝试一下。 Remember, you do NOT have to use sudo to install RVM. 请记住,你不必使用sudo来安装RVM。 It should install into your home directory without any complaints. 它应该安装到您的主目录,没有任何投诉。

Also, I don't think we've established what version of the OS, or of XCode you are running. 另外,我认为我们没有确定您正在运行的操作系统版本或XCode版本。 You might want to download Apple's most recent version of XCode for your OS from their website. 您可能希望从他们的网站下载适用于您的操作系统的Apple最新版本的XCode The version that came with Snow Leopard on the DVD has some bugs and should be upgraded ASAP. DVD上附带Snow Leopard的版本有一些错误,应该尽快升级。 If you don't have a developer account then create one. 如果您没有开发者帐户,请创建一个。 They're free. 他们是自由的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM