Cannot use gem and ruby command after install on Vista - ruby-on-rails

I installed Ruby and Ruby on Rails yesterday on Vista 32bit using the directions on this site: http://rubyonrails.org/down
So I downloaded the installer, then Gems, then I downloaded rails with Gems.
Now I can't use the Gem or Ruby commands in the command line... so I assume there's something wrong with the environment variables, but I hav eno idea how to set them up in Vista or what to put.
Can anyone help me with this?

To set up the environment variables, do this
Fire up the start menu
Right-Click on Computer and select Properties
Click Advanced system settings in the left-hand bar, and confirm the UAC prompt
Select the Advanced tab (it's 3rd)
Click Environment Variables... (at the bottom)
In the top box (User variables for XXX) either find the entry for PATH, or click new to create the entry.
If there is already a PATH use semi-colons to seperate each directory listed in it
Put c:\ruby\bin (change if you installed ruby somewhere else) in.
Click OK a lot of times to close all the windows we opened.
Restart your command prompt.
gem and ruby and irb should now all work. Whoever said that GUI tools are slower than command line tools. pshaw!

In the command line window type PATH then hit return, do you see ruby.exe on the PATH environment variable?
If you installed ruby to say c:\ruby then it'll be c:\ruby\bin\.
Looks like it may be missing from the path.

Add your ruby bin directory to your PATH environment variable, go to Control Panel -> System -> Advanced system settings, then go to the Advanced tab, Environment Variables, then edit your PATH variable and append the path to the ruby binaries install i.e. ;C:\ruby\bin

Related

How do I setup the ruby SDK in IntelliJ IDEA?

I've been using this guide
Whenever I go to import the module I get this screen:
I used the following file path, maybe this is whats wrong?
/usr/local/Cellar/ruby-build/20160130/share/ruby-build/2.3.0
And got this error:
I'd appreciate any ideas anyone might have, i've been trying get this working all night!
I ran into this problem with Intellij IDEA 2020.2. It took a while to resolve because the Intellij documentation seems to be missing one critical piece.
When you first open a project in IDEA, it assumes all your code is part of a Java module. With that module in place you cannot set a Ruby SDK at the module level. There's no option to do because the existing module is configured as Java.
Here's a screenshot of my example project with the default Java module. Notice the icon is a folder with a blue rectangle in the lower, right corner.
Here's what I had to do.
Open the Project Structure dialog (File | Project Structure).
In the Modules settings, highlight the top-level project module and click the delete button (looks like a minus sign).
Click the plus sign to add a new module.
From the pop-up click "New Module".
In the "New Module" pop-up select Ruby and the correct Module SDK (e.g. rbenv: 2.5.0)
When you are prompted to enter the Module name, Content root, and Module file location, make sure the directories are set to your project's root. When I entered the module name it appended the name to the project's root directory which is probably not what you want.
Once you've done that the module should appear with a Ruby icon on it and the rest should work as documented here: https://www.jetbrains.com/help/idea/configuring-language-interpreter.html
Here's a screenshot of my new Ruby module. You can see the Ruby icon replaced the blue rectangle.
I hope this saves you some time!
In order to set Ruby SDK for your project in IDEA you need to go to File | Project Structure | Project Settings and set project and module SDK.
Olivia is correct, the "Project Structure..." (Mac shortcut Cmd+;) is the dialog for configuring the IDE to use different ruby installations.
The first requirement is that the ruby manager (chruby, rbenv, rvm) is configured properly.
Another concern is exactly where and how jetbrains expects the ruby installation to be organized. I wonder if Intellij is compatible with the way ruby-install lays out ruby? That's the one I used with chruby. I could not make it work.
The posted url to Opening Rails projects in IntelliJ IDEA helped me feel the most confidence that we are on the right track. :)
At the time, I was failing to get Intellij configured due to fact the gem files were not seen by the IDE. All but about 4 gems in my project's Gemfile was being highlighted as having an SDK problem.
To end this, I stopped using chruby and ruby-install. I am not blaming chruby, however I could not make the chruby system work properly with the IDE. It worked fine in the shell. Note, I am a previous user of rvm and rbenv. Switching back to rbenv, now. Note that I've also stopped using ruby-build directly.
Instead, I built the first ruby version directly from rbenv:
rbenv install 2.3.1
Next, I created the .ruby-version file in the root of my rails project directory by running:
rbenv local 2.3.1
To help with any confusion regarding the minimum support needed in the shell startup scripts. Do not alter PATH at all. Place the following in your shell startup script system, whatever that may be:
# rbenv config in my .bash_profile
# --------------------------------
if which rbenv > /dev/null; then
eval "$(rbenv init -)";
fi
With the prerequisites out of the way...
I recommend doing the project import in the same way described in the jetbrains tutorial Opening Rails projects in IntelliJ IDEA.
In the first screenshot from thesowismine, I see two dialogs for different purposes that are simultaneously open. Unless I am mistaken, one of those dialogs should have received its info and closed before going forward, at least during the wizard-like process. Perhaps this was done and that dialog was reloaded later?
In any event, that is not where the Ruby SDK is associated to a Rails project. The screenshot indicates the User is browsing around the brew Cellar, which may indicate two things.
Ruby was installed with a brew install <version> command; I installed ruby by calling the rbenv ecosystem.
That particular dialog is for informing the IDE about the Rails project folder, not the Ruby kit.
Assuming the first dialog is provided with the root directory of the Rails app and next is clicked; then in the second dialog, I change nothing and click next. The 3rd dialog is where I confirm the project directory is correct and I can assign a more elaborate name (which is displayed in the IDE's project menu). Clicking next may prompt you to write over the ".idea/" directory. Say yes. The next dialog confirms that sources were found. Click next. Now Frameworks begin to be detected assuming the Ruby Manager is setup correctly. Click Finish.
Now, goto the "Project Structure..." dialog to set the SDK.
Before or after setting the SDK, go to the the project directory of your Rails project, run:
gem install bundle
bundle install
This will install all the gems your project requires including the rails gem, as presumably it is listed in your Gemfile.
Note that gemsets do not come up, here. In this config, the set of gems are associated to a particular Ruby installation. Bundler is your friend.
Languages & Frameworks > Ruby SDK and Gems
I was able to solve this by doing:
Preferences | Plugins | Install JetBrains plugin

How do I open a ruby gem in Sublime on Windows 7 using command prompt?

I have added Sublime's directory to the system path, so when I enter "subl" in comman promot it opens the Sublime, that's fine. But,
When I tried to open a ruby gem, I remembered the command used in Linux etc which is "bundle open xyz", I entered this command to Windows 7's command prompt it gave me an error as "To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR".
I assumed that I must mention that i wanna open it through sublime, so I edited the command as "subl bundle open sass", but it opened a new file named ''bundle open sass'' in sublime (not the sass gem).
Does anyone know how to open a ruby gem in sublime or whatever editor from command prompt in Windows?
Thank You!
Edit: After pdobb's answer I created a variable named EDITOR in my environment variables, and set its value to subl (I assumed that the path is not needed along the "subl" because its path is already set in the path variable), but now its showing the error as "Could not locate gemfile", but when I list my gems its there.
Here is the snapshot of how I set the EDITOR variable.
The command is bundle open xyz, as you've said. The editor you want to use is set in the $EDITOR or $BUNDLER_EDITOR environment variable. In effect, bundler checks this environment variable for what editor to open the gem in. So, you just need to set the environment variable $EDITOR to subl. This is done in the same place as where you set your $PATH environment variable. See here for a guide.
you can go to the directory where the gem is installed and open the directory with your editor.
For example,
If the ruby gems are installed on .rvm/ruby-2.1.0/gems/. Let's say, you want to open 'capybara' gem. then open the .rvm/ruby-2.1.0/gems/capybara in your editor

gem install rails -y doesn't work with ruby 2.1.6 in Windows 8

Hi experts about Ruby.
I'm pretty new on this fantastic and funny language, but I immediately meet an error with my command prompt.
I typed, because Win8, gem install rails -y but system said: "gem" is not a batch command or file and bla bla bla..
Why this?
How can i resolve?
This usually happens if you didn't check the “Add Ruby executables to your PATH” box during the Ruby installation process. In that case your environment won’t know where your Ruby installation is situated. There are two ways you can fix this:
1. You can try reinstalling Ruby.
Remember to check the "Add Ruby executables to your PATH" box during the installation process.
2. You can also try to fix it manually:
Start menu -> Right click on Computer -> Properties -> Advanced system settings (in the left panel) -> Advanced tab -> Environment Variables button
In the User variables section, double click on Path (or select Path and press Edit).
If there is anything else there put a semicolon after it ; and add the path to your Ruby bin folder
Example C:\Ruby193\bin or C:\Ruby200\bin
Then press OK
NOTE: the 3 digits are the version of your Ruby installation. Just go to your C: drive and check the name of the Ruby folder.
Now in the System variables section, press New. For variable name enter RYBUOPT and for variable value rubygems Press OK on the small window and on the other two that remained opened.

Ruby on Rails -- new install on windows 7 but cant run ruby commands, problem with path?

I just installed ruby on rails on my new computer ( I was using instantrails before) and I'm trying to get everything setup.
Im running Windows 7. So I followed the instructions from this tutorial.
http://blogupstairs.com/ruby-on-rails/installing-ruby-on-rails-on-windows-7/
The problem i'm guessing is step 3
"Add the newly installed bin directory to your path in your windows system : Open windows explorer-> right click the icon computer-> choose Properties -> in the contol panel Home, Click Advanced system settings and then click Envitonment Variables button->in the system variables click new and add new system variables like this : Variable name : RUBY_HOME , Variable Value : C:\Ruby, after that add it in to the path and add the bin after a semicolon to the “Path” variable like this : C:\Program Files\Common Files\Adobe\AGL;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%RUBY_HOME%\bin"
I set created the system variables but when I try to run script/generate in the main directory of my app I get the error
"Ruby: no such file or directory --script/generate"
I checked the apps directory and the script folder is in there. How can I run the "ruby script/generate" commands from the control panel?
I was guessing it was something with the path but I dont know any ways to check to find out whats going wrong.
Are you using Rails 3.0+? In this version of rails and up, the script/* folder has been deprecated in favor of rails generate, rails server, etc. See here.
In 99.99999% of all cases, if a computer tells you that it cannot find a file at a specific location, it is because that file is not at that specific location.
So, is there actually a file named generate in a directory named script in the current directory?
I have recently installed RoR on my "clean" Win7 as well.
What IDE are you using?
I suggest trying JRuby with NetBeans/RubyMine:
JRuby installer does all the work (even adds the proper variables to your path in system environment settings...,
IDEs take care of gems, setting up servers etc.
As for the commands, as Nuclearsandwitch mentioned, there is no script/generate or script/server in Rails 3. Just make sure you in the directory with your Rails app and then try running rails server. It should work :-)

"rails" command on windows

So I installed Ruby On Rails using the Windows Installer.
Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??
The CMD command line in Windows does not recognize "rails"
I don't think it is an PATH problem, because when I'm in the "Bin" directory, there is "rails.bat" and "rails" with no extension. If I run Rails.bat I get "The filename, directory name, or volume label syntax is incorrect."
I get that message with whatever Argument I pass to it.
It seems to be a bug in the rails.bat file because of double-quotes, like:
#"ruby.exe"" "%~dpn0" %*
Remove the double quotes:
http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html
To get a terminal
Start > Run... or Windows key + R
Type "cmd" and hit enter.
To add a folder to the command line's path
On Windows XP (Vista is similar)
Start > Control Panel > System
Click the "Advanced" tab
Click "Environmental Variables"
Under "System Variables" double click on Path and edit accordingly.
You will need to open a new command line in order to get the updated path to take affect. With XP, I've had to reboot to force it to take affect but it shouldn't be necessary.
The Path variable is a semi-colon seperated list of folders in which the Command Line or "terminal" looks for commands.
You'll probably have to find the rails command yourself. I would try looking for a rails.bat or rails.cmd file.
I think they mean the command window. Try running it from a command line.
I dont know where the Windows Ruby on Rails intaller places its files, but the ultimately solution is that you need to make sure that the "rails" command is is your PATH - which you can view/modify by right-clicking My Computer, selecting Properties, going to the Advanced tab and then clicking on "Environment Variables" and then scrolling down until you see "PATH" and adjusting it accordingly. You probably need to find the directory where the "rails" command lives and append to the end of the existing PATH entry, inserting a ";" before you enter the new path to append it to the existing PATH.
So find where "rails" is and add its directory to your PATH.
You probably have to change your PATH in Windows to point to wherever the rails executable has been installed.
The PATH environment variable is used to determine where Windows looks for stuff; when you type, for instance, 'calc' Windows will hunt through its PATH and eventually find and run C:\Windows\calc.exe. In your case, the PATH doesn't include the directory you need, so Windows isn't searching in that directory for rails.exe when you type "rails."
To fix this, right click on "My Computer" -> "Properties" -> "Advanced" -> "Environment Variables" and then modify the PATH one to include the directory your rails.exe is in.
I recommend using cygwin for Rails development on windows - far too much of the community is using *nix. If you install the development tools package you'll automatically have svn, git and other doo-dads that you'll eventually need relating to various rails plugin installation. If you want to deploy using capistrano the installation is identical to all the instructions you find. Plus other tips and tricks people will reference will work exactly the same for you as it does for them, whereas some things are different for native windows and all the accessory tools have to be installed separately.

Resources