Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRicardo Cardoza
2,024 PointsCreated a workspace, tried installing money gem but I keep getting FilePermissionError
Here's the error message:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/lib/ruby/gems/2.1.0 directory.
Sean Flanagan
33,235 PointsI downloaded the Ruby gem that Jason referred to and uploaded it to Workspaces but I got the same FilePermissionError message that I got when I tried to install the gem normally. I'm open to alternatives, for which people will have my advance gratitude.
I think Jason's a great teacher. I've done all of the preceding ten courses in the Ruby track and enjoyed learning what I've learned, but I think Jason might have assumed that students have access to something that's off-limits to us. Maybe he was unable to anticipate that we would have this problem; naturally we humans aren't clairvoyants. But I think that when writing future courses, it would pay not to automatically assume that it's going to be accessible to the whole Team Treehouse community.
8 Answers
Nate Meyer
3,887 PointsHi!
The issue here is that we do a system installation of Ruby inside of a workspace, which means a "gem install" tries to write to a directory that the unprivileged treehouse
user doesn't have access to.
I strongly encourage folks to not chmod system directories to work around this as some previous posters described. Instead, just install gems to a location your user already has access to. This is controlled via the GEM_HOME
environment variable. So to follow along to Jason's video:
# make the directory to save our gems
treehouse:~/workspace$ mkdir -p ~/.local/gems
# export the GEM_HOME environment variable
treehouse:~/workspace$ export GEM_HOME=~/.local/gems
Now gem installation should work:
treehouse:~/workspace$ gem install money
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: money-6.6.1.gem (100%)
...
2 gems installed
And you can use them:
treehouse:~/workspace$ irb
irb(main):001:0> require 'money'
=> true
We're going to fix this on our end, but in the meantime you'll need to do this manually when you launch Ruby workspaces until we can get that shipped.
Sorry for the inconvenience!
Sean Flanagan
33,235 PointsHi Nate and thank you. I've just followed your advice to the letter and it seems to be working.
Unfortunately, when I typed cd .local/
, all I got was: No such file or directory
. So what should I do now?
Nate Meyer
3,887 PointsSean Flanagan, when you launch a workspace you are not in your home directory. You're in ~/workspaces
. You can see this with the 'pwd' command. So, what you're actually want to do is cd ~/.local
.
Sean Flanagan
33,235 PointsHi Nate. Thanks again. Just to let you know I've typed in cd ~/.local
and I got treehouse:~/.local
.
Philip Bessa
5,396 PointsI tried using workspaces as well (oh great, can't copy/paste so I have to type the error manually):
Fetching: i18n-0.7.0.gem (100%)
ERROR: While executing gem . . . (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/lib/ruby/gems/2.1.0 directory.
So I assume Jason has administrator privileges and we don't, there's not much reason to emulate what he's doing.
Garrett Carver
14,681 PointsYou are right, I tried this myself and I got the same issue. It looks like the workspaces commandline doesn't give us any admin privileges. What I would do instead is install ruby on your local machine. Follow this guide depending on which operating system you have. I also had to add the ruby directory to my system path, so I could the commands like 'ruby' and 'gem' without having to use the full path. (follow these instructions if you are on Windows. Add the following to your system path ;C:\Ruby22\bin
)
Let me know if you have any trouble with this.
Cheers,
Sean Flanagan
33,235 PointsHi Garrett. I downloaded Ruby 6.6.1 and edited my system path as you suggested but when I try to use the Ruby program, I just get a pop-up message saying there's no program associated with it. Thanks all the same and I'm open to other ideas.
Ben Jakuben
Treehouse TeacherHi Sean (and everyone),
I am sorry about this issue! I'm not sure what the root cause is, but I've opened an issue with our Workspaces team to take a look and fix it ASAP.
Garrett Carver
14,681 PointsInstead of adding ;C:\Ruby22\bin
you will need to add the correct folder to your system path in order to use the commands from your ruby installation on your local machine. Find the folder that contains ruby.exe (by default, it's located on your C: drive) and add that to your system path.
Sean Flanagan
33,235 PointsHi Ben. Thank you for your response. I'd better link you to this thread which I think will offer a way around for non-Ubuntu users.
https://teamtreehouse.com/community/filepermissionerror
I think that Jason was using Ubuntu when he wrote this course and that he didn't take into consideration the fact that not everyone uses Ubuntu. He might have assumed it would work on all platforms, with all operating systems.
This should help: chmod 777 -R /usr/local/lib/ruby/gems
Type it in before installing the gem. It worked for me and hopefully it will for everyone else. Credit and thanks to Seth Reece for coming up with this.
Hannah Flynn
21,429 PointsThis code will be what you people are looking for:
gem install money
Sara Greer
16,032 PointsCan't say for certain without seeing command line output, but be sure you are in the correct directory before installing the gem.
Garrett Carver
14,681 PointsAre you using workspaces? I am not sure if this helps but try using:
sudo gem install money
Sean Flanagan
33,235 PointsHi Garrett. I tried your suggestion but all I was:
-bash: sudo: command not found
Thanks anyway.
Ricardo Cardoza
2,024 PointsRicardo Cardoza
2,024 PointsBtw the command I ran was (as per the lesson):
$ gem install money