unable to run PhantomJS under cygwin using absolute paths - cygwin

I am not able to run PhantomJS under cygwin using absolute paths for the argument .js file. Here are the steps I took to setup PhantomJS:
Downloaded PhantomJS 1.9.7 for windows
Copied the PhantomJS executable to c:\cygwin64\bin\
Copied the file "hello.js" from the unzipped PhantomJS download file to my cygwin home directory
Started cygwin/xterm
If I run:
which phantomjs
in my cygwin xterm, it correctly responds with:
/usr/bin/phantomjs
If I run the following from my home directory:
phantomjs hello.js
PhantomJS correctly responds with:
Hello, world!
If I on the other hand run this:
phantomjs /home/user1/hello.js
PhantomJS replies:
Can't open '/home/user1/hello.js'
If I run this:
/usr/bin/phantomjs /home/user1/hello.js
PhantomJS still replies:
Can't open '/home/user1/hello.js'
It does this for every absolute path I try. Why won't PhantomJS work with absolute file paths? The path I showed in my example doesn't have any spaces, special characters, etc., so I'm not sure what the problem could be.
I also tried running the same test in a command prompt under windows and sometimes it would exhibit the same behavior, but not always. I can't seem to reproduce this error under windows anymore so I'm not sure what else to say about that.
Does anyone know what the problem could be?

I found the solution. Running native windows programs through cygwin requires you to convert cygwin's POSIX paths to Windows-style paths. In my example above, the following works:
phantomjs "`cygpath -w /cygdrive/c/cygwin64/home/user1/hello.js`"
returns:
Hello, world!
I am not yet sure what the backticks are for, but at least I found the solution.

Related

selenium-webdriver: The geckodriver executable could not be found on the current PATH

I installed the selenium webdriver using the following command:
$ npm i selenium-webdriver
Then, I created the directory D:\WebDriver\bin (and added the files geckodriver.exe and operadriver.exe to that directory) and added it to the system's PATH variables.
The PATH to the directory that contains both drivers was successfully added, as can be seen below:
$ printenv PATH
/mnt/d/WebDriver/bin/
$ ls "/mnt/d/WebDriver/bin/"
geckodriver.exe operadriver.exe
I am also able to run the geckodriver via cmd.exe (Same applies to operadriver):
C:\Users\user>geckodriver
1621873805268 geckodriver INFO Listening on 127.0.0.1:4444
When I try to run one example file (google_search) via:
/mnt/d/proj/node_modules/selenium-webdriver/example $ node google_search.js
I receive the following stacktrace:
Error: The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
The operadriver also cannot be found when setting up an example that uses the opera driver.
Worth mentioning is that I use a Windows Subsystem for Linux (WSL) and ran the commands (node, printenv and npm) in the terminal of that subsystem. The path variable was set on the Windows system and the required drivers were only installed on the Windows system. I can access the installed files on my windows system via the WSL terminal, but selenium still cannot find the specific driver(s).
When I run the above mentioned test file (google_search.js) from selenium-webdriver on the Windows system, it does find the web driver and works as expected. I still cannot figure out the reason why the driver is not being found in the WSL.
I was able to resolve the problem using the following well written article: https://qxf2.com/blog/setup-linux-testing-environment-on-windows-using-wsl/. By creating symlinks that point to the driver and the web driver executable, the driver and the web browser was found. For now, I do think it's easier to run the tests in cmd.exe, though, as it does not require these additional steps.

BrowserSync in Bash on Ubuntu on Windows (Linux Subsystem) - couldn't open browser

I use browser-sync in Bash, it doesn't auto-open browser and says [BS] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false) when I type npm start in Angular example.
Of course there's no option to open a browser in limited Linux environment (since no GUI support provided in Bash on Ubuntu on Windows).
If I use Powershell, it's working OK.
My environment: VS Code + Bash on Ubuntu on Windows.
But is there a config or workaround?
So while I kept browsing, i found a clue to the solution of this problem on this webpage https://gist.github.com/Kenty/9096000/revisions which hinted me of where i could find the open option from the error message. I decided to searched for "bs.config.js" on my pc and i found a file called default.config.js in my \Template\node_modules\browser-sync\lib folder under my angular folder and when i searched through the file, i finally found the open option and changed the open option from "local" (which is the default option) to false (Note, it's without the quotes) and when i ran the npm start command again, on the git-bash terminal It worked and there were no more errors.

PyInstaller on Linux (Ubuntu) -- open executable in console

Running PyInstaller v3.2 on Ubuntu 16.04, is it possible to get my bundled application to open a console for stdout? On Mac and Windows I can get this to work, as outlined in the options documentation. But nothing is mentioned for Linux. I've tried playing around with the -c flag, but that does not seem to have any effect. I also tried bundling it as a single file (-F) versus a directory, but neither seems to open a console for stdout...
Just for future reference, in Linux if you run a bundled app from the command line like a script, it will automatically use that same terminal as stdout ...

teach me how to set up a path correctly

I installed casperjs by npm install command on my mac os x.
But, when I try using casperjs in command line, it gives me the error below.
$ casperjs cas.js
-bash: /usr/local/bin/casperjs: No such file or directory
I checked if casperjs is installed by using which command.
The result is below.
$ which casperjs
-bash: /Users/Hayato/.nodebrew/current/bin/casperjs
I think what I need to do is to setup a path in a different way so that when I run "casperjs test.js", it runs "/Users/Hayato/.nodebrew/current/bin/casperjs" instead of "/usr/local/bin/casperjs".
But, I'm not familiar with this kind of terminal task, and don't know how to do this.
Please could anyone teach me how to setup a path correctly?
Thanks!
If you want to use casperjs in the directory you specified, add this to your ~/.bash_profile
export PATH=/Users/Hayato/.nodebrew/current/bin/:$PATH
Save the file
That will add all scripts in the /Users/Hayato/.nodebrew/current/bin directory to your path.
After that.. close the terminal and then reopen it:
You can check the path by doing:
echo $PATH
You should see the path you just added.
Then when you do the following:
which casperjs
it should use the new location.
Let me know if this works for you!
But, the issue may be something deeper, did you get errors when you installed casperjs via brew?
You may want to try linking it again using
brew link casperjs
If that doesn't work you may have some permission issues.
Check out these previously answered questions:
brew link didn't complete
Fixing homebrew permissions

Node.js Cygwin not supported

I am trying to install node.js. I followed this tutorial and i am stuck in the middle.
When I write ./configure in my cygwin terminal it says "cygwin not supported". Please help me out
Thanks in advance.
Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.
In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it
export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"
If you run a 32 bit version of node:
export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"
Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:
dos2unix '/cygdrive/c/Program Files/nodejs/npm'
At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:
cygstart /bin/bash
This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.
Also note that you can run any one line node code in MINTTY by just running something like:
node -e "console.log('hello node')"
As a simpler derivative of troy's answer for those just looking to install NPM packages:
Install Node.js with the Windows installer package.
Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/" (obviously replacing the path to Node.js's installation directory with where you installed it).
There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
Test it. Eg, npm install pretty-diff -g.
In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).
Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).
Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P
Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html
With Bjørn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babun v1.02, a Cygwin distribution.
For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.
C:\Users\郷>bash
郷#CHIGIX ~
$ node
>
I'm using this wrapper in /usr/local/bin/node (note no extension!)
#!/bin/sh
_cmd="$(cygpath -lw -- "$1" )"
shift
"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$#"
This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.
From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.
Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.

Resources