App running on Windows 10 machine can't find file - ruby-on-rails

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.

Related

Why is my WSL2 enviornment referencing Java folder outside its virtual environment?

When I start my development rails server I get this following message first. To my knowledge WSL2 is a virtual environment.
I would have expected it to now reference a Java directory that resides on my Windows host. Is this likely something I carried over in the project from when I was using WSL1? How would I safely correct this?
/home/daveomcd/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/app_loader.rb:53:
warning: Insecure world writable dir /mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
in PATH, mode 040777
I experienced the same problem when trying to fix the slowness of WSL2. The recommended solution was to move the files from the mounted NTFS drive to the root ext4 filesystem (using \\$wsl\<distroname>), so I did that.
I set up /etc/wsl.conf as below:
# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=0033"
mountFsTab = false
[interop]
enabled = true
appendWindowsPath = true
And ran rails bundle to update dependencies.
Also make sure that your file permissions and owner settings are updated. Hope it helps.
Sorry, I'd love to make this more of a comment to see if I'm on the right track before committing to an answer. However, since there's too much info here for that, I'll make an attempt at getting you an answer here.
While it is a virtual environment, by default WSL provides several "Windows Interop" features that allow it to:
automatically mount Windows drives in /mnt/{c,d,...}
append the Windows path to the Linux path
run Windows executables inside Linux
share Windows environment variables with Linux (although this is not something that happens by default)
I can't be sure (long, long time since I've used Rails), but it looks like something in the app_loader.rb is checking permissions on Java directories in the path. It may be using some logic like "check each path entry and look for a java or java.exe there. If found, check permissions." Or something like that. That means that (2) and (3) above may be confusing it.
You can see this in action with which java.exe, which will likely return a Windows path. Or run notepad.exe, which will launch the Windows Notepad executable from within Linux/WSL (magic! 😉).
These are both very useful features, so I hate to disable them completely, but it's the easiest way to figure out if that's the problem. Create a /etc/wsl.conf with the following contents:
[interop]
enabled=false
appendWindowsPath=false
Exit your WSL instance and then:
(from PowerShell, CMD, or Windows Start) Run wsl --list --verbose to see the name of your distribution (most likely Ubuntu)
Likewise, run wsl --terminate <distro> to terminate that distribution.
Restart your WSL instance
Try running /mnt/c/Windows/system32/notepad.exe (assuming a normal C:\Windows installation) (should fail, since interop is disabled)
Try which notepad.exe (should fail, since the Windows path should no longer be appended to the Linux path)
Try to start your Rails dev server again - Might work (might not, I could easily be wrong about the root-cause here)
If it does work, then you can try to correct the situation with several less invasive methods than disabling those features entirely:
If you plan on only using WSL for your development, then you could remove the Windows JDK.
Or at least remove the Windows JDK from the PATH in Windows.
Or, if you want to keep it installed and in the Windows path, you could have a shell startup file (e.g. .bashrc) that removes it from the path only in WSL. I'll point you to this question which contains multiple techniques for doing so.
Or you could keep the appendWindowsPath=false in your /etc/wsl.conf but then add back in the paths you want manually in your startup config.

Delphi 5 Installation Error

I am trying installing Delphi 5 on my computer. As soon as the installation starts I get:
Error copying File
followed by:
Setup has detected a -113 error while attempting to copy files. This
indicates that setup could not find a file in the "RunImage" directory.
Now the setup file does includes "RunImage" directory. The File is located in the D drive on another computer which I have mapped to my computer as Drive Z and I am running it from the Mapped Drive Z.
I searched online for this Error. Some recommend that if I am installing from a network location then the location has to mapped to my computer as a Driver with a name to solve the issue. I did map the location but still getting the same error.
As J.. already suggested in his comment: Windows >= Vista automatically runs programs containing the string "setup" in the name in elevated mode. In that mode, you don't have the same mapped drives as in your normal user mode. So, the program starts (which is actually inconsistent with security model, because in elevated mode, the executable itself should not be available) and then cannot find any additional files because the drive mapping does not exist.
Solution: Copy the whole installation directory to a local drive. You can delete it after the installation has finished.
Note: While I think this will solve that particular problem, it does not mean, that the rest of the installation will work.
i had same problem and i solved it by this method:
After unpacking the archive(the delphi5 zip file that you downloaded), make the root directory with the command Subst X: "path to installer". Run the standard Borland installer, the Install.exe program, there.

Yeoman. The filename, directory name, or volume label syntax is incorrect

Reinstalled Windows 10 (Version 10.0.14393). Reinstalled the following:
Java
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
nodejs (v6.9.5)
NPM (3.10.10)
Yarn (v0.19.1)
Yeoman (installed with yarn global add yo)
When I write yo -v in cmd in any folder, runned with administrator or not, I take:
The filename, directory name, or volume label syntax is incorrect.
UPDATE:
The only workaround I found is to use the full path of yo:
C:\Users\<username>\AppData\Local\Yarn\config\global\node_modules\.bin\yo.cmd
It may be that your PATH does not point to global NPM modules yet. The FAQ and links are more helpful for gnu/linux or mac users. The PATH is a list of the places that your operating system checks whenever you type a command.
Since you are using Windows, to add the modules path temporarily (just for one session) at the prompt, just type (obviously use the correct path with your correct username and please take note of the ; separator character):
path = %path%;C:\Users\<username>\AppData\Local\Yarn\config\global\node_modules\.bin\
You should then be able to run 'yo -v' without pointing to the full path name, since the console now knows to check that folder also. If that works for you, you can add that path permanently using the instructions described on another SO post here.
Finally (and this is only slightly related to your question), since i notice you've got the Windows 10 anniversary update, if you have Linux experience, you may prefer to use "Windows subsystem for Linux", which is a bash shell (Ubuntu 14) on Windows, that you can use instead of the default command prompt. You can find it under "Add / Remove programs --> Turn Windows features on or off --> (scroll right down) --> Windows subsystem for Linux (beta)". Your local file system will be at "/mnt/c" so you can get to it from within the shell or from windows explorer. I've had fewer problems using this and since so many tutorials are written with bash (not command prompt) in mind, it's useful to use it instead of cmd.
You'll need to install dependencies in the usual way using apt-get (as it won't use the ones you've installed on the windows side) and you'll need to prefix commands that make system changes with 'sudo'. e.g.
sudo npm -g modulename

Error while installing jruby on windows 7

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.

Windows x64 RabbitMQ install error with Erlang environment var (ERLANG_HOME)

I'm ask/answering this question because it hung me up & it's likely someone else will have the same problem.
Install of RabbitMQ x64 v2.8.6 on Windows Server 2008 x64.
After Erlang install using default install location to C:\Program Files\erl5.9.2, I'm attempting to start the server via running the rabbitmq-service.bat. Fail:
Please either set ERLANG_HOME to point to your Erlang installation
or place the RabbitMQ server distribution in the Erlang lib folder.
Problem is the .bat file does not have the correct subpath. with 5.9.2 (R15B02) version of erlang. My ERLANG_HOME directory is set correctly, but the script does not use it correctly for this version of Erlang, which, it appears to this Erlang noob to have a new subdirectory called "erts-5.9.2" which is causing the problems. Maybe someone intimate with these scripts can describe how to make this work correctly without the hack workaround I'm about to describe?
1- Set environment variable:
Variable name : ERLANG_HOME
Variable value: C:\Program Files (x86)\erl6.4
note: don't include bin on above step.
2- Add %ERLANG_HOME%\bin to the PATH environmental variable:
Variable name : PATH
Variable value: %ERLANG_HOME%\bin
This works well.
There are several RabbitMQ control .bat files on windows. Every one you use needs to get changed to reflect the Erlang path correctly. In this example, I'm editing the rabbitmq-server.bat because it's one of the easier ones... any of the .bat files you want to run will need this hack to get them to work, with the rabbitmq_service.bat file being the most involved to adjust.
editing that rabbitmq_server.bat file, you can see on about line 48 or so there's a check to see if the erl.exe is found, but the path isn't correct:
if not exist "!ERLANG_HOME!\bin\erl.exe" (
that path does not match the file structure for the 5.9.2 version of Erlang. I fixed this by simply removing this path check from about line 48 to 58, then, where the .bat actually makes a call to the erl.exe on about line 129 which reads:
"!ERLANG_HOME!\bin\erl.exe"
I simply hardcoded the path to my erl.exe:
"C:\Program Files\erl5.9.2\erts-5.9.2\bin\erl.exe"
With the pathing correct, the rabbitmq .bat files will run.
I had the similar issue, modifying ERLANG_HOME in .bat files did not work. Then I tried echo %ERLANG_HOME% in command prompt, that did not print the environment variable value(I could see that ERLANG_HOME environment variable has been created under advance system settings), that lead me to believe that I need to restart server for 64 bit installation of Erlang. After rebooting server, It worked like a charm. I hope this helps someone.
Just to share an up-to-date answer as of 2019: On Windows Server 2019, after setting up the environment variable, a restart is required to solve the problem.
I got into same kind of problem.
I solved it by doing three changes as given below.
Update Path variable "ERLANG_HOME" : "C:\Program Files\erl8.0" in Environment Variables.
Upadte "Path" variable "Path" : ";%ERLANG_HOME%\bin;"
Give urself FULL CONTROL permissions over "Program Files" in C drive.
It worked for me in this way.
This problem still occurs in Erlang 18.3 (erl7.3) and RabbitMQ 3.6.9 on Windows when upgrading from any older version of RabbitMQ to version 3.6.9. The solution as already stated here is to manually set ERLANG_HOME with 'setx -m ERLANG_HOME "C:\Program Files\erl7.3"' before starting the service.
What happens is that the RabbitMQ 3.6.9 installer removes the environment variable ERLANG_HOME from the system while removing the older version of RabbitMQ. Then, when it proceeds to the installation step, it does not put back the ERLANG_HOME variable. Then, the batch files that start up RabbitMQ cannot find Erlang. They try to find Erlang's home directory using "where.exe" but it always fails after an upgrade.
RabbitMQ's installer also does not kill all of the Erlang background processes, causing many of its files to be undeletable due to the Windows "file in use" problem. This leaves behind "files in use" in %APPDATA%\RabbitMQ and "C:\Program Files\RabbitMQ." These processes are "erl.exe," "erlsrv.exe," and "epmd.exe." The RabbitMQ installer should taskkill these processes after shutting down the RabbitMQ Windows service.
RabbitMQ is rather clunky on Windows.
Download Erlang or OTP - Only one Version of OTP should be installed
Download RabbitMQ installer
Install both exe file as Administrator
Set class path for Erlang. (Setting classpath is a bit troublesome, so follow these steps)
Set a new path with name ERLANG_HOME and value C:\Program Files\erl-23.1 (do not copy bin folder here)
Edit System "path" and add %ERLANG_HOME%\bin
Go to Start - Open rabbitmq command promt and run
rabbitmq-plugins enable rabbitmq_management
Navigate to localhost:15672
Use guest/guest to login
Interesting that this worked for you. There is record of a two bugs in Erl5.9.2 that cause an incomplete installation where %ERLANG_HOME%\bin is not installed.
Either of
* Installed 64bit erlang on 32bit machine
* "The program can't start because MSVCR100.dll is missing from your computer."
https://groups.google.com/d/topic/erlang-programming/wGtFLzapiQ0/discussion
Try 5.9.1 or any other version. They also mention making the future versions of the installer alert you if it fails.
I just had the same problem mentioned here. I installed otp_win64_R15B02 on a Windows 7 machine and everything worked perfectly, but I used the same installer on a Windows 2008 server and the bin directory was not created. I then uninstalled otp_win64_R15B02 and downloaded the otp_win64_R15B02_with_MSVCR100_installer_fix and the bin directory was created.
I suspect the reason it worked on my Windows 7 system is that I have Visual Studio installed and the required libraries were already available which allowed the otp_win64_R15B02 installer to work correctly.
Oh, and if you're installing Erlang to run RabbitMQ the RabbitMQ install will succeed with the broken installer but installing otp_win64_R15B02_with_MSVCR100_installer_fix after RabbitMQ will not work, just un-install and re-install RabbitMQ to resolve this.
Just give C:\Program Files\erl10.6\ not C:\Program Files\erl10.6\bin\erl.exe in the environment variable. If you open the server.bat file I came to know the issueenter image description here
I think this is encoding issue on windows.I see a correct value but I write echo %ERLANG_HOME% on console the value come with question mark. These steps fix it.
1.go environment variable window
2.edit ERLANG_HOME item
3.copy the value, open notepad and paste there
4.copy again on notepad and paste to edit window
5.apply and exit window
6.close command line tools and reopen
7.run rabbitmq bat file.
I solved it in a quick and dirty way,without naming path variables
I've opened the bat file and replaced every occurrence of
!ERLANG_HOME!\bin\erl.exe
with hard coded path for example might be diffrent path for you because of diffrent version
C:\Program Files\erl10.3\erts-10.3\bin\erl.exe
and replaced
%RABBITMQ_HOME%\escript\rabbitmq-plugins
with
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.14\escript\rabbitmq-plugins
Even I was this problem. The issue was the environment variable ERLANG_HOME=c:\Program Files\erl9.0 which was never existed.
I cross checked the path. The correct path was c:\Program Files\erl9.3.
After correcting the
ERLANG_HOME=c:\Program Files\erl9.3
the problem solved. So, definitely it is a path issue.
In my case, it should be installed erlang using admin role running
If above solutions doesn't work for you then you can try following
Find another compatible version of erlang for your rabbit mq e.g. for rabbit 3.7.x erlang version 20.3.x to 22.0.x all are compatible .
Right click newly downloaded erlang version and from properties select the option to unblock the file .
Run the erlang with admin persssion .
Re run rabbit mq exe

Resources