I'm learning to use Bootstrap and spent the last few hours wrestling with Terminal as I tried to install the software that accompanies it - Ruby, Rails, SASS and two or three more. It was a failure, though I did get most of the programs installed.
Now it appears that Rails has hijacked my Terminal. I tried installing another toy I wanted to try out, Symfony. When I type in the install command
$ curl -LsS http://symfony.com/installer > symfony.phar
$ sudo mv symfony.phar /usr/local/bin/symfony
$ chmod a+x /usr/local/bin/symfony
I get this message:
-bash: $: command not found
Davids-MacBook-Pro:Rail myname$
I get the same message if I type in $ php --version
Anyway, the word "Rail" leads me to suspect that Terminal is in Rails mode. Can anyone tell me how to turn it off? I wasn't allowed to ask about it on the Apple forum; they seem to have a problem with questions related to this topic. ;)
Thanks.
P.S. I'm using OSX Yosemite.
The commands to install symfony, make sure you enter them one at a time and don't include the $ which is causing the error.
You can configure what appears currently as
Davids-MacBook-Pro:Rail myname$
by going typing cd to go to your home directory and than nano .bash_profile
By the way Bootstrap is just a css, html, and a bit of javascript framework/library that you can use with a bunch of different languages doesn't have to be Ruby on Rails. Also ruby is installed on yosemite by default but you might need to update it and Rails automatically includes SASS (Both Rails and SASS are gems).
The :Rail in Davids-MacBook-Pro:Rail myname$ indicates that you're currently in a folder named Rail. There is no "Rails mode," and Rails will not "hijack" your terminal.
Type the pwd command to reveal which folder you're in (which I'm guessing is a folder named Rail).
If you cd into another folder, your command prompt will update to reflect that:
Davids-MacBook-Pro:Rail myname$ cd ~/Desktop
Davids-MacBook-Pro:Desktop myname$
Related
When I create a scaffold in terminal, I get the above error message. I have type the following command first:
echo "source \$HOME/.rvm/scripts/rvm" >> ~/.bashrc
I still get the following error:
WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
Any help will be greatly appreciated.
Try running the command source ~/.bashrc and then re-running rails. If that doesn't work, a different approach may be needed.
The problem is that as far as your OS is concerned, Rails doesn't exist. There could be multiple reasons for this. Seeing that you're using rvm, rvm is supposed to tell Ubuntu where to find rails.
Make sure that you are using the correct version of ruby specified in your Gemfile by typing rvm current. Make sure you are using the correct version when running bundle install, otherwise the gems will be installed under a different ruby version.
Also, make sure that the ~/.rvm directory exists and that the path specified in your .bashrc file is correct.
Let me know if any of these suggestions help.
Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails and made it about 1/2 way through yesterday. When I stopped for the day, I closed out iTerm2 and shut off the Macbook Pro. Today, I powered up, opened iTerm, navigated to my working directory (~/rubyonrails/learn-ruby) and entered rails -v.
I see this:
`Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.`
So I run sudo gem install rails and it shows that it has installed rails-4.1.0. Now rails -v still gives me the same error message above.
I tried also running rvm use ruby-2.1.1#learn-rails first and I still get the error message.
So I'm a little stuck and I can't figure out what to do to get rails working. Also, how do I go about setting up the bash environment such that I don't have to go through this each time? It would be nice to nav to my working directory and just start work without having to do a bunch of re-installation and reconfiguration each time.
Regards,
Jeff
please type in your shell:
$ bash --login
and then repeat your commands.
rails -v
Also try to call it with the full path:
like:
/your/path/to/rails -v
I think that the shell just doesn't know where rvm/rails etc is located.
You can solve this by entering:
$ source ~/.rvm/scripts/rvm
When you switch to the ruby-2.1.1#learn-rails ruby/gemset combo, and do gem list, what do you see?
The way people usually use rvm is to have every project folder specify the ruby & gemset it uses (they don't all have to be different). This is done with files called .ruby-version and .ruby-gemset. These should contain, in your case, ruby-2.1.1 and learn-rails respectively.
Set these if you haven't already, then leave the folder and enter it again. Then do bundle install to install the gems for the project into the rvm/gemset combo.
Your problem is that you ran
sudo gem install rails
The error message telling you to do this comes from your system Ruby, which doesn't know that you want to use RVM.
RVM installs gems into your user-space directory. By using sudo, you're bypassing this and installing it into (effectively) the superuser space, i.e. globally.
If you instead just run
gem install rails
then you'll be using RVM's copy of the gem utility rather than the globally installed version.
I recently upgraded to Ruby 2 and Rails 4
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
$ rails -v
Rails 4.0.0
Now, when I create a new rails app, when the bundle install part happens, I get asked for my system password, which never used to happen before. It also takes forever. Reference screenshot: http://i.imgur.com/6kh4g63.png
Secondly, whenever a gem shows up in my Gemfile which I don't already have, it requires installation. In this case, I flat out get a permission denied error. Reference screenshot: http://i.imgur.com/rcIq5Vq.png
Also, when I want to run "rake db:migrate", I have to run it with sudo now, whereas previously this wasn't the case. If I do sudo bundle install, then even my Gem installation problem gets fixed.
However, this is not how my workflow used to be, and I want to figure out why this is suddenly the case. Even my rails server which I previously could start by simply typing "rails s" now requires me to type "sudo rails s".
Does anyone know what is causing this and how I can fix it?
Thank you.
Okay, so I think I've solved it. Not sure if this is good practice or not, but it worked, so I thought I'd answer it:
First, I found out where my rails is located, by typing: "which rails"
It gave me: /usr/local/rvm/gems/ruby-2.0.0-p247/bin/rails
So I went to that folder: cd /usr/local/rvm/gems/ruby-2.0.0-p247/bin
I saw that everything was owned by root. So I changed that to my username:
sudo chown -R Myname *
I did the same for ruby: "which ruby"
cd /usr/local/rvm/rubies/ruby-2.0.0-p247/bin
sudo chown -R Myname *
I thought this would work, but when a new gem would install, the folder it would try to copy in would not have write permissions for my username. This folder was: /usr/local/rvm/gems/ruby-2.0.0-p247/build_info/
So I did: cd /usr/local/rvm/gems/ruby-2.0.0-p247
And then owned the folder: sudo chown -R Myname build_info
And voila, everything is working now.
Please correct me if this is bad practice or unsafe.
Thank you.
I'm new to Ruby on Rails and have just set it up in Ubuntu Linux following instructions I found here. Specifically,
As s.m. said, I uninstalled everything, then I opened another terminal session as a normal user and run:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
then i run source /home/my-desktop-username/.rvm/scripts/rvm as a normal user NOT ROOT
then i run rvm requirements as a normal user. Then I copy the requirements and close the session, open a root session and install the requirements using sudo
Then I close the session and open a normal user session and run rvm install ruby-1.9.3-p125 if you run this command as root, it will say that rvm is not installed and will suggest that you install it using sudo apt-get install rvm Don't do that!
So basically I had two problems, the tutorials that i followed didn't say that i should run
source /home/my-desktop-username/.rvm/scripts/rvm and didn't say that I should not run rvm as root, s.m told me that. Thanks to everyone, especially to s.m
That works well, but I will have to remember to
source .rvm/scripts/rvm
every time I open a terminal to work with Ruby on Rails.
Is there a way to permanently tell Ubuntu to look in .rvm for all the Ruby stuff?
You need to add your
source .rvm/scripts/rvm
into your $HOME/.bashrc file; read the advanced bash scripting guide for more.
After the reboot which was required to update all the packages,
ruby -v
doesn't work. It says rails is not installed either, but I guess it should be the similar issue. when I do:
sudo apt-get install ruby
It says the newest version is already installed.
When I do:
dpkg -L ruby
I get the following output:
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
[and other stuff..]
But I realized $PATH already includes /usr/bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/home/ubuntu/.rvm/bin
May I know why I'm still getting the following error message?:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
My .bashrc already has this too:
PATH=$PATH:$HOME/.rvm/bin
dpkg will be checking in a database that it maintains, whereas trying to execute ruby uses the PATH. If I recall correctly, Ubuntu has a bash handler configured to execute when any command is unresolvable; it seems that it just displays that generic message rather than checking with dpkg first.
It is possible that ruby has disappeared from your filesystem (or at least the directory it previously resided in), or that your PATH was changed.
What do you get if you execute "which ruby" and "where ruby"?
Lastly, Ubuntu can complain that a program cannot be found when it is present. This occurs when running a 64-bit version of Ubuntu, without the necessary x86 libraries installed, and trying to execute a 32-bit binary. However, I recall the error message being more along the lines of "file not found".