No such file or directory in VScode - ruby-on-rails

Does anyone has a solution for this error?ยด
dan#LAPTOP-U61VD2F3:/mnt/c/Users/danyl/Desktop/New folder$ ruby "c:\Users\danyl\Desktop\New folder\Lesson.rb"
Traceback (most recent call last):
ruby: No such file or directory -- c:\\Users\\danyl\\Desktop\\New folder\\Lesson.rb (LoadError)
dan#LAPTOP-U61VD2F3:/mnt/c/Users/danyl/Desktop/New folder$

Solution in this case:
Go to your settings.json file in Vscode and add this line into the settings:
"code-runner.terminalRoot": "/mnt/",
or you can open settings and find Code-runner: Terminal Root and type this:
/mnt/
Note: For Windows system, replaces the Windows style drive letter in the command with a Unix style root when using a custom shell as the terminal, like Bash or Cgywin. Example: Setting this to '/mnt/' will replace 'C:\path' with '/mnt/c/path'

Related

Running PY file outside of Spyder

I used to be able to double click .py file and it would proivde me CMD prompt to run the script.
At the moment I have to go into Spyder each time to run the file.
What do I need to do to be able to run outside of Spyder?
Thanks
open a terminal/cmd in the directory the file is in and then write python pythonFile.py
EDIT
alternative option, open Powershell in the directory the file is in or open powershell and navigate to the directory the file is in and use this command to source a document in the current directory ./test.py

Trying to read an mp3 file in ruby

I am looking a read an mp3 file currently located in my public folder.
I have tried the following:
2.5.3 :016 > audio_file = File.new('/demo.mp3', 'rb')
And it resulted with the following error:
Traceback (most recent call last):
3: from (irb):16
2: from (irb):16:in `new'
1: from (irb):16:in `initialize'
Errno::ENOENT (No such file or directory # rb_sysopen - /demo.mp3)
I would assume this is pretty straight forward but for some reason it does not work. Does anybody knows how to do that ?
Alternatively, would it be possible to read a file that is located in a server via an http://xxxxxxx.xxxxx/xxxx/mp3 for example ? (This is where the file is located initially).
You've got the wrong path. /demo.mp3 will look for the file at the root of your file system.
If it's in public/, then you need to specify the path using the relative path public/demo.mp3 since the app is running from the project folder (supposedly) which contains the public/ folder.
You can also use path "#{Rails.root}" + "/public/demo.mp3"

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.

Neo4j start trouble?

I get the following error for all the below mentioned error: What could be problem. Is the problem with java path OR the Neo4j package itself, as some of the stack overflow answer suggest OR linux permission issue?
Starting Neo4j.
./neo4j: line 149: /usr/Neo/neo4j-enterprise-3.0.6/bin/run/neo4j.pid: No such file or directory
-bash-4.1$ ./neo4j: line 148: /usr/Neo/neo4j-enterprise-3.0.6/bin/logs/neo4j.log: No such file or directory
For all the below version:
neo4j-community-3.1.0-BETA1 or
neo4j-enterprise-3.0.6 or
neo4j-enterprise-3.1.0-BETA1
If you look closely at the paths, you'll see that it's trying to write files in sub-directories under bin, whereas they are actually next to bin:
/usr/Neo/neo4j-enterprise-3.0.6/bin/run/neo4j.pid
/usr/Neo/neo4j-enterprise-3.0.6/bin/logs/neo4j.log
Even though you should be able to start Neo4j from inside the bin directory, it seems on your machine it fails to determine the base Neo4j directory. Is bash installed? Or have you set NEO4J_HOME to /usr/Neo/neo4j-enterprise-3.0.6/bin in your shell?
Try starting Neo4j directly from its base directory instead:
cd /usr/Neo/neo4j-enterprise-3.0.6
bin/neo4j start

Biopython cannot find file

I am trying to run a qblast from the Python prompt and after importing all the libraries I need, Python cannot find my file:
>>> record = SeqIO.read(open("sinchimeras_1.fasta"), format="fasta")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'sinchimeras_1.fasta'
I have tried to write down all the route for the file ("/Users/imac...") and to move the file to the Python and to the Biopython folders, and I get the same message.
Where do I have to save my file? What am I doing wrong?
You need to move that file to your working directory or use an absolute path.
This problem is independent of Biopython; the IOError is coming from open("sinchimeras_1.fasta").
Explanation
When you provide Python the relative path "sinchimeras_1.fasta", it looks in the current directory for such a file. So, instead of moving your Fasta file to a Python/Biopython folder, ensure it's in your working directory (os.getcwd() may be helpful).
Alternatively, you can supply the absolute path to the file in place of "sinchimeras_1.fasta" (e.g. open("/Users/imac.../sinchimeras_1.fasta")).

Resources