Error while installing jruby on windows 7 - ruby-on-rails

I am trying to install JRuby in my system, I follow the following steps:
Download a copy of the latest JRuby from the JRuby download page.
Unzip the file with your achive program. If you don't have one that works, download 7-Zip.
Copy the JRuby folder called jruby-1.7.2 directly to "C:/"
Set environment variables on your system. Right click "My Computer" go to "Advanced" then "Environmental Variables". Create these: JRUBY_HOME = C:/jruby-1.7.2
Next you'll have to edit the PATH variable. Add ;C:\jruby-1.1.5\bin; to the end of that variable.
And then I am running the command:
C:\Users\sitanshu\rubyApp\jruby-1.7.2>jruby -v
then it shows the following error:
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.7.0-ea-b19 [Windows Vista-x86]
NameError: uninitialized constant Java::JavaLang::ProcessBuilder::Redirect
const_missing at org/jruby/RubyModule.java:2677
ProcessManager at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:12
JRuby at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:6
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:3
load at org/jruby/RubyKernel.java:1046
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel.rb:1
So where am I going wrong and what is the solution for that?

I would test that java is updated and working
java -version

Under your environment variables, make sure you have a JAVA_HOME variable pointing to your JRE root folder, like this:
C:\Program Files\Java\jre7\
Make sure your Java JRE bin folder is also part of your PATH variable:
;C:\Program Files\Java\jre7\bin\
Additionally, when you are adding jruby to your PATH variable, make sure you are referencing the correct folder location. In the example you have given, you are installing jruby to C:\jruby-1.7.2, but then you are actually referring to this different folder C:\jruby-1.1.5 in your PATH configuration.
Also, when you are defining your JRUBY_HOME variable, make sure you are using backslash \ characters. In your example above you used a forward slash / character. Remember, that windows uses backslashes between folders.
Finally, after you've made all your environment variable changes, remember to open a new command window for your changes to take effect.

Related

JAVA_HOME or PATH or BOTH?

I was watching the Android development video and they asked us to install JDK and create JAVA_HOME environment variable.
I already have MyEclipse installed and I previously had setup the PATH variable(giving it the directory of JDK), do I still need a JAVA_HOME variable ??? If yes then why ???
Yes, you do need.
PATH is usually used to lookup the executables so that you haven't to specify the whole path to execute. JAVA_HOME may be used by the scripts or IDEs to lookup libraries. You can specify JAVA_HOME and build path variable basing on it. E.g (depending on OS)
PATH=$PATH;$JAVA_HOME/bin
Short answer, YES, you do need to set JAVA_HOME.
You can read here the difference between each one of them, but I'm pasting the explanations below as well:
JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.
CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. You do not normally need to set the CLASSPATH environment variable. Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands.
PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. The JDK installation instructions explain how to set PATH.
If the application you are using is looking for a specific dataset in the JAVA_HOME environment variable and it isn't there, it is not going to be happy.
Other applications might look for the JDK path in the PATH environment variable, but just because you have it there doesn't mean it will work for other applications that need it in a separate variable.

App running on Windows 10 machine can't find file

I had an app using chromedriver on a Linux machine, and I switched the app over to a Windows 10 machine. Now suddenly it's telling me that it can't find the chromedriver file.
Here's error:
Selenium::WebDriver::Error::WebDriverError in Static#home
Showing C:/Users/User/Documents/test_app/app/views/static/home.html.erb where line #4 raised:
Unable to find chromedriver. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
I placed the chromedriver file in the same place it was on my Linux machine, right in the main folder of the app. In this case the path is C:\Users\User\Document\test_app. Does Windows interpret paths differently than Linux?
The chromedriver is the latest release. It's titled "chromedriver_win32.zip". The "win" means Windows. Could the "32" mean it's for a 32-bit system? My machine is 64-bit.
If you put the chromedriver.exe in the folder Chromedriver_win32.zip which is in the same folder as your script, you can set the driver_path to that file. See code below:
require "selenium-webdriver"
Selenium::WebDriver::Chrome.driver_path = File.join(File.absolute_path('./', "Chromedriver_win32.zip/chromedriver.exe"))
driver = Selenium::WebDriver.for :chrome
driver.get "https://www.google.com.sg/"
I don't have any knowledge on ruby or ruby-on-rails. please find the equivalent in java or python in Windows OS.
Two ways:
you can keep Chrome driver in a place where it is added to PATH variable (environment variables in Windows 10)
Programmatically set the path to the executable chromedriver.exe
For Java:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
For Python : (we keep chromedriver.exe in C:\Python27\Scripts location. this location is already added to PATH variable when python (Activestate) is installed. in case, chromedriver.exe is not in one of the PATH locations, you can specify as follows)
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
For Ruby:
Add the ruby installation path to Windows PATH environment variable and keep chromedriver.exe in that location. (Windows searches for binaries in the locations specified in PATH variable.)
For more info on setting ruby installation location to PATH
https://stackoverflow.com/a/26947536
References:
https://sites.google.com/a/chromium.org/chromedriver/getting-started
I would put this in as a comment, but, since I'm relatively new, I am forced to put it in as an answer, which it might well be...
Pardon me if I'm asking the obvious, but, did you try "unzipping" the file and putting the ".exe" file into that directory? The file you mentioned (you said.. titled "chromedriver_win32.zip") is not an executable file in Windows. The file you should be looking for is chromedriver.exe.

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.

Cannot use gem and ruby command after install on Vista

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

Resources