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 trial
Patricia Snyder
5,563 PointsMac OS Mavericks permission denied on terminal
I recently updated to Mac OS Mavericks and I can no longer run .rb files in my terminal window. I'm getting the following line when I try and run the file.
-bash: /Users/username/Desktop/rubyfiles/test.rb: Permission denied
I'm pretty sure I was able to run the files before the update. I've tried changing permissions, but I'm too new at working with a Mac terminal to know what I'm doing.
I am VERY new to working with the Mac Terminal, so I'm hoping this is a simple fix.
Thank you for any help you can give me.
4 Answers
ixrevo
32,051 PointsHi Patricia!
Try to use sudo https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/sudo.8.html
Type sudo and then other commands that you trying to execute.
Patricia Snyder
5,563 PointsHi Alexander,
I got this to work by changing the directory to my desktop and then typing ruby test.rb. I had been taught that I could drag and drop the file into the terminal and it would run. I remember it running that way before I updated to Mavericks, but then again, I've been switching between my Mac and PC. I could have used that method on my PC and not the Mac.
This is what I got before.
Last login: Wed Jul 2 18:51:01 on ttys000 Trish-Snyders-MacBook-Pro:~ trishsnyder$ /Users/trishsnyder/Desktop/test.rb -bash: /Users/trishsnyder/Desktop/test.rb: Permission denied Trish-Snyders-MacBook-Pro:~ trishsnyder$
Is there a way to just drag and drop a ruby file into the terminal?
Thanks! Trish
ixrevo
32,051 PointsHi Patricia,
I'm sorry for delay of my answering.
I've found an easy way to execute ruby scripts without sudo on Mac.
Just type ruby before a path to a ruby script. There are my examples below (I use OS X 10.9.4):
13:00 ixrevo@ixrevos-macbook Desktop $ cd
13:00 ixrevo@ixrevos-macbook ~ $ ruby Desktop/test.rb
Hello World!
13:01 ixrevo@ixrevos-macbook ~ $ ruby /Users/ixrevo/Desktop/test.rb
Hello World!
13:01 ixrevo@ixrevos-macbook ~ $ cd Desktop/
13:01 ixrevo@ixrevos-macbook Desktop $ ruby test.rb
Hello World!
When you drag and dropping a file into the terminal you just use a shortcut for typing an absolute path to a file. You know the difference between an absolute and relative path to a file, do you?
Seemingly, when you give to the terminal just a path to a ruby script, terminal doesn't understand how to evaluate this script. But when you type ruby before the script, you tell to the terminal: hey, it's a ruby script, I want you to execute it.
There is a very good course on Treehouse: http://teamtreehouse.com/library/console-foundations-2 It contains a lot of useful basics of using the terminal.
I hope I was helpful. Any way I'm ready to answer any your further questions.
Patricia Snyder
5,563 PointsCool! Thank you! I'll give that a try.
Patricia Snyder
5,563 PointsHey Alexander, That worked! Thanks!
Patricia Snyder
5,563 PointsPatricia Snyder
5,563 PointsHi Alexander. Thanks for answering so quickly! I've tried sudo, but I may just not be doing the right thing. I appreciate the link and will take a look at the documentation and see if I can get this sorted out.
ixrevo
32,051 Pointsixrevo
32,051 PointsCould you demonstrate here your input and output of Terminal? I mean copy/paste your commands that doesn't work and what Terminal output in response. I think, it will increase my ability to help you and solve this problem quickly.