user502052
user502052

Reputation: 15258

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.

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

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.

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

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

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

Notice: this time I used bundle install instead of 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. It doesn't when I use the basic installation of apache from 'Snow Leopard' on the URL http://project.local. Why does it happen?!


EDIT (after a request in an answer)

The output of rvm info is:

/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

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

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

Upvotes: 3

Views: 2419

Answers (1)

the Tin Man
the Tin Man

Reputation: 160621

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

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.

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.

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.

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.


Edit: rvm info shows "bad brokage".

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

locate rvm | grep -v /Users

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

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


EDIT: "I founded:"

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/

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

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.

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.

At this point rvm should be removed from your machine.

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.

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.

Upvotes: 3

Related Questions