Does not set permission properly for downloaded drivers
When downloading drivers, it looks like the code is supposed to try to modify the permissions so the files are executable but it is not.
Version: 5.8.0 Node Version: 0.12.17
Can you share more info about your environment (platform, how you or another tool is calling selenium-standalone, etc.) and what types of errors you are seeing?
I tried with my local machine (OSX 10.10) and didn't immediately notice anything not working.
$ node -v
v0.12.17
$ cat node_modules/selenium-standalone/package.json| grep version
"version": "5.8.0",
$ ./node_modules/selenium-standalone/bin/selenium-standalone install
----------
selenium-standalone installation starting
----------
---
selenium install:
from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
to: /private/tmp/selenium-standalone-253/node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip
to: /private/tmp/selenium-standalone-253/node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.10.0/geckodriver-v0.10.0-macos.tar.gz
to: /private/tmp/selenium-standalone-253/node_modules/selenium-standalone/.selenium/geckodriver/0.10.0-x64-geckodriver
selenium-standalone installation [================== ] 88% 2.6s
-----
selenium-standalone installation finished
-----
$ ls -AlR node_modules/selenium-standalone/.selenium
total 0
drwxr-xr-x 4 sash wheel 136 Jan 7 09:33 chromedriver
drwxr-xr-x 4 sash wheel 136 Jan 7 09:33 geckodriver
drwxr-xr-x 3 sash wheel 102 Jan 7 09:33 selenium-server
node_modules/selenium-standalone/.selenium/chromedriver:
total 29984
-rwxr-xr-x 1 sash wheel 10782984 Jan 7 09:33 2.25-x64-chromedriver
-rw-r--r-- 1 sash wheel 4563462 Jan 7 09:33 2.25-x64-chromedriver.zip
node_modules/selenium-standalone/.selenium/geckodriver:
total 9184
-rwxr-xr-x 1 sash wheel 3457020 Jan 7 09:33 0.10.0-x64-geckodriver
-rw-r--r-- 1 sash wheel 1243480 Jan 7 09:33 0.10.0-x64-geckodriver.gz
node_modules/selenium-standalone/.selenium/selenium-server:
total 41472
-rw-r--r-- 1 sash wheel 21231092 Jan 7 09:33 2.53.1-server.jar
From the directory listing at the end of all of that shows that all the driver binaries have +x set (the archives don't but that's okay).
I am on macOS 11.12 though this same problem existed on 10.11 and 10.10 for me. Selenium standalone is being called from grunt task. None of the files it downloads have the permissions modified. I did some testing and https://github.com/vvo/selenium-standalone/blob/13c15ee1b48b0dc1aa12c809e05de4c22541b866/lib/install.js#L369 is never called. The function never produces an error so the permissions are never changed, even when the file is not executable.
I tried to replicate this locally, but haven't gotten the file permissions to silently fail like you are describing. For example, when the file exists but is owned by another user, the chmod function is called and fails with an EPERM error.
I've added some quick debug log statements around that section of code that might help us track things down more. Can you try changing the dependency in your package.json to https://github.com/vvo/selenium-standalone.git#feature/debug-logging and running npm install again. That will get my new code. Then when you run, turn on the logging with DEBUG=selenium-standalone:* grunt ...
Along with the output from the debug logs, can you do a ls -AlR node_modules/selenium-standalone/.selenium (or whatever you are using in opts.basePath) before and after the grunt run? Your comment in #254 leads me to believe that you already have the files from your SCM and that could be contributing to this issue.
@stephenash Here is the output from the debug statements: $ DEBUG=selenium-standalone:* grunt selenium:install selenium-standalone:env-details Platform: darwin +0ms selenium-standalone:env-details Architecture: x64 +2ms selenium-standalone:env-details Node.js: v0.12.17 +2ms Running "selenium:install" (selenium) task selenium-standalone:install Install API called with { basePath: '/Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium', version: '3.0.1', baseURL: 'https://selenium-release.storage.googleapis.com', drivers: { chrome: { version: '2.25', arch: 'x64', baseURL: 'https://chromedriver.storage.googleapis.com' }, ie: { version: '2.53.1', arch: 'ia32', baseURL: 'https://selenium-release.storage.googleapis.com' }, firefox: { version: '0.11.1', arch: 'x64', baseURL: 'https://github.com/mozilla/geckodriver/releases/download' } }, logger: [Function] } +245ms [Selenium install]: ---------- [Selenium install]: selenium-standalone installation starting [Selenium install]: ---------- [Selenium install]: [Selenium install]: --- [Selenium install]: selenium install: [Selenium install]: from: https://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar [Selenium install]: to: /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/selenium-server/3.0.1-server.jar [Selenium install]: --- [Selenium install]: chrome install: [Selenium install]: from: https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip [Selenium install]: to: /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/chromedriver/2.25-x64-chromedriver [Selenium install]: --- [Selenium install]: firefox install: [Selenium install]: from: https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz [Selenium install]: to: /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/geckodriver/0.11.1-x64-geckodriver [Selenium install]: --- [Selenium install]: File from https://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar has already been downloaded selenium-standalone:install unzip /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/chromedriver/2.25-x64-chromedriver.zip +1s [Selenium install]: [Selenium install]: [Selenium install]: ----- [Selenium install]: selenium-standalone installation finished [Selenium install]: ----- selenium-standalone:install setDriverFilePermissions /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/chromedriver/2.25-x64-chromedriver +420ms selenium-standalone:install setDriverFilePermissions /Users/christophertaylor/Desktop/Collage.com/scrapwalls/util/selenium/geckodriver/0.11.1-x64-geckodriver +0ms
Done, without errors.
$ ls -AlR util/selenium/ total 0 drwxr-xr-x 10 christophertaylor staff 340 Jan 17 00:48 chromedriver drwxr-xr-x 7 christophertaylor staff 238 Jan 17 00:48 geckodriver drwxr-xr-x 5 christophertaylor staff 170 Jan 9 10:47 selenium-server
util/selenium//chromedriver: total 116120 -rw-r--r-- 1 christophertaylor staff 10782984 Jan 17 00:48 2.25-x64-chromedriver -rw-r--r-- 1 christophertaylor staff 4563462 Jan 17 00:48 2.25-x64-chromedriver.zip
util/selenium//geckodriver: total 37568 -rw-r--r-- 1 christophertaylor staff 3330688 Jan 17 00:48 0.11.1-x64-geckodriver
I narrow the output to the relevant files. The file only has read permission. This occurs when the file is newly downloaded.
@CTaylor1118 Thanks for the debug logs. They do show more of what you were describing, but I'm not finding the why quite yet.
If you run that block of code in the node REPL, does it think that file has +x set?
$ node
> process.version
'v0.12.17'
> fs.access('downloads/chromedriver/2.25-x64-chromedriver', fs.R_OK | fs.X_OK, function(err) {
... console.log(err ? 'no access!' : 'has +rx');
... });
> has +rx
The only other thing that I can think of is that there is something funny with existing files. I tried with existing versions of the drivers that were owned by another user, that folder no write permissions, that came from another platform, etc. Still haven't gotten the repo steps yet.
If you set the opts.basePath in the install step to a brand new folder, does this still happen for you? Maybe try with a folder in /tmp?
Wow !
If we refere to Darwin/Mac OS X's manual :
Even if a process has appropriate privileges and indicates success for X_OK, the file may not actually have execute permission bits set.
(
at the end => "Access() is a potential security hole and should never be used."
Ok, no troll, it's the same on all platforms !
)
Well, let's get back to serious, I pushed an additional debug in the #feature/debug-logging branch, @CTaylor1118 can you try again and past the output ?
If stat outputs a the real mode (rw-r-r), then we can workaround by doing a fs.stat() and compare mode with uid/gid etc.)
Please try the latest version.
Feel free to re-open if the issue persists.
Thanks!