Using elm-test in a git hub action - elm

I want to use the an git hub action to test and build my elm package whenever a commit is pushed to the master branch for this my action .yml file looks like this
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
sudo npm install -g elm-test # this fails
elm-test
elm make
for testing I want to use elm-test which can be installed via npm but the command sudo npm install -g elm-test fails with
/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test
> elmi-to-json#1.3.0 install /usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json
> binwrap-install
ERR Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
at Object.mkdirSync (fs.js:823:3)
at /usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:46:10
at new Promise (<anonymous>)
at untgz (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:21:10)
at binstall (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:11:12)
at install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/install.js:20:10)
at Object.install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/index.js:14:14)
at Object.<anonymous> (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/bin/binwrap-install:18:9)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.2 (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elmi-to-json#1.3.0 install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elmi-to-json#1.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-03T17_50_06_232Z-debug.log
Any advice on how to install elm-test inside a git hub action?
Edit:
Without the sudo the error becomes
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-04T13_41_34_534Z-debug.log

Thanks to #toastal comment I found another solution. That is to set up a package.json file using npm and then adding elm-test as a dependency with the command
npm install -D elm-test
also you might want to add node_modules to your .gitignore to ignore npms installation folder.
Then in the yml file you can just run the command npm install and elm-test gets installed.
Then you can call it with
./node_modules/elm-test/bin/elm-test
My yml file now looks like this
name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- name: install npm dependencies
run: npm install
- name: Test
run: ./node_modules/elm-test/bin/elm-test
- name: check documentation
run: |
elm make --docs=docs.json
rm docs.json

Thanks to #glennsl I found a solution: specifying where npm installs package globally.
Since the runner that runs the action has no access to the /usr/local/lib npm can't install anything on a global level.
The solution (as described here) is to create a folder as a "global" installation folder and configuring npm to use it. It is also necessary to add the new folder to the PATH environment variable.
So my yml file now looks like this
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
PATH=~/.npm-global/bin:$PATH
npm install -g elm-test
elm-test
elm make

Related

npm uninstall -g create-react-app Error: EPERM: operation not permitted

When creating a new react app with npx ( npx create-react-app new_app --use-npm --template typescript) I get the following error:
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
Yet running npm uninstall -g create-react-app I get a permissions error:
npm WARN locking Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'
npm WARN locking C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock failed [Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'] {
npm WARN locking errno: -4048,
npm WARN locking code: 'EPERM',
npm WARN locking syscall: 'open',
npm WARN locking path: 'C:\\Users\\MYCOMP~1\\AppData\\Roaming\\npm-cache\\_locks\\staging-abfecabb8ac6a958.lock'
npm WARN locking }
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'
npm ERR! [Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Users\\MYCOMP~1\\AppData\\Roaming\\npm-cache\\_locks\\staging-abfecabb8ac6a958.lock'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
PS C:\Users\Primary User\Desktop\seisolosite\newseisolosite\CSS3DDemo> npm uninstall -g create-react-app
npm WARN locking Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'
npm WARN locking C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock failed [Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'] {
npm WARN locking errno: -4048,
npm WARN locking code: 'EPERM',
npm WARN locking syscall: 'open',
npm WARN locking path: 'C:\\Users\\MYCOMP~1\\AppData\\Roaming\\npm-cache\\_locks\\staging-abfecabb8ac6a958.lock'
npm WARN locking }
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'
npm ERR! [Error: EPERM: operation not permitted, open 'C:\Users\MYCOMP~1\AppData\Roaming\npm-cache\_locks\staging-abfecabb8ac6a958.lock'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Users\\MYCOMP~1\\AppData\\Roaming\\npm-cache\\_locks\\staging-abfecabb8ac6a958.lock'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
Running yarn uninstall -g create-react-app works just fine:
yarn global v1.22.10
[1/2] Removing module create-react-app...
[2/2] Regenerating lockfile and installing missing dependencies...
info fsevents#2.3.2: The platform "win32" is incompatible with this module.
info "fsevents#2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
warning "depcheck > #vue/compiler-sfc#3.1.5" has unmet peer dependency "vue#3.1.5".
success Uninstalled packages.
Ok great, so I should be set now, right??
But then I run npx create-react-app my-app --template typescript and get the same error, we We no longer support global installation of Create React App.. Restarting the computer and running the command in a new terminal does nothing. Retrying with yarn instead of npx doesn't work either, running yarn create react-app my-app --template typescript gives error:
'C:\Users\Primary' is not recognized as an internal or external command,
operable program or batch file.
So I'm pretty much completely stuck, with neither yarn or npx working with creat-react-app. Any clues on how to get one of them working?
OS: Windows 10

How do you install Firebase tools in a Gitlab CI Runner?

I'm having some trouble configuring Gitlab CI to run firebase emulators. In particular, it's failing to install firebase-tools. This is the relevant part of my config
unit-test-job: # This job runs in the test stage.
image: node:14.14.0
artifacts:
paths:
- "test-results.xml"
reports:
junit: "test-results.xml"
stage: test
script:
- apt-get update && apt-get install -y openjdk-8-jdk
- npm i
- npm i -g firebase-tools
- firebase use $MY_PROJECT
- echo "Running unit tests..."
- npm run test:ci
When trying to install firebase-tools I get this error from the CI
$ npm i -g firebase-tools
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
> re2#1.16.0 install /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.br ...
Writing to build/Release/re2.node ...
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
> re2#1.16.0 rebuild /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> node-gyp rebuild
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.14.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp'
gyp ERR! System Linux 5.4.109+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/re2
gyp ERR! node -v v14.14.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2#1.16.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the re2#1.16.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any suggestions on how to fix this?
You're actually encountering an issue that isn't necessarily related to gitlab-ci, but it actually related to node 14. Essentially that /root/.npm folder has bad permissions in node 14. You have three ways you can fix this:
Update to Node 15 (just change your image to node:15) which fixes the permission issue
Allow node permissions to scan the folder. This is insinuated by the error message you have in the above error where it tells you the directory can't be scanned. The easiest way to resolve this issue is to remove the -g off the second node install, which will make it deploy to the user folder instead of global. Since you're rebuilding the container every time and using the same user each time, the -g to install globally is redundant in this case.
Install Firebase using the standalone method to get the CLI instead of using NPM to install it. You can do this in a docker container using curl -sL firebase.tools | sed 's/sudo //g' | bash
Hopefully this helps!

How to update npm in Laravel Sail

I am currently using Laravel 8.48.2 with the Sail package. I set Sail up and running its image through Docker Desktop while using WSL 2 with a Ubuntu distro on Windows. All seems to be working fine.
After I ran sail npm install, the packages were installed successfully, but I received the following message:
npm notice New minor version of npm available! 7.18.1 -> 7.19.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.19.0
npm notice Run npm install -g npm#7.19.0 to update!
Therefore, I tried running sail npm install -g npm#7.19.0 which gave me the following message:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/npm
npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/npm',
npm ERR! dest: '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sail/.npm/_logs/2021-06-26T15_27_02_291Z-debug.log
How can I update the NPM version on Sail?
Thank you in advance.
Current working method:
sail root-shell
npm install -g npm#latest
Looking at your log it seems the user you run as has insufficient permission on the folder /usr/lib/node_modules/. So what you might try is to log in to the container with docker-compose exec laravel.test bash and use chown -R user:group /usr/lib/node_modules/ with the current user and group (found by whoami). Or chmod the folder to have more looser permission overall on this folder.
Thanks to #online Thomas (https://stackoverflow.com/a/68173952/14508436), in order to resolve my issue, I followed these steps:
Within my Laravel project's directory, I ran this command... docker-compose exec laravel.test bash, which points you to the docker's server (or something like that), directly on your project's directory.
I ran this command... npm install -g npm#7.19.0 which updated npm to a newer version without any issues.
I tried the chown and chmod commands as suggested by #online Thomas, but in vain. I still couldn't use the sail npm install -g npm#7.19.0 command outside of the docker's server.

When installing Expo, I get 'permission denied' errors

When i try to install the Expo SDK, I get permission errors:
sudo npm install exp --global
> #expo/traveling-fastlane-darwin#1.2.5 preinstall /usr/local/lib/node_modules/exp/node_modules/#expo/traveling-fastlane-darwin
> node platform.js
/usr/local/bin/exp -> /usr/local/lib/node_modules/exp/bin/exp.js
> spawn-sync#1.0.15 postinstall /usr/local/lib/node_modules/exp/node_modules/spawn-sync
> node postinstall
> #expo/ngrok#2.3.0 postinstall /usr/local/lib/node_modules/exp/node_modules/#expo/ngrok
> node ./postinstall.js
ngrok - error unpacking binary { Error: EACCES: permission denied, open '/usr/local/lib/node_modules/exp/node_modules/#expo/ngrok/bin/ngrok'
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/usr/local/lib/node_modules/exp/node_modules/#expo/ngrok/bin/ngrok' }
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: #expo/traveling-fastlane-linux#1.2.5 (node_modules/exp/node_modules/#expo/traveling-fastlane-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for #expo/traveling-fastlane-linux#1.2.5: wanted {"os":"win32,linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #expo/ngrok#2.3.0 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #expo/ngrok#2.3.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chris/.npm/_logs/2018-01-27T10_59_33_236Z-debug.log
I'm using npm 5.5.1 + node v8.9.1 + macOS high sierra
You really shouldn't be using sudo with npm at all. I would say please fix your permissions or as a more immediate solution, npm install --dev exp, so it becomes a devDependency to your project.
This command works for me sudo snap install ngrok
This worked for me:
sudo npm install --unsafe-perm -g expo-cli

Global install of phantomjs-prebuilt in Debian stretch

I'm trying to do a global install of phantomjs-prebuilt in a Debian Stretch VM. I realise there is a prebuilt Debian package, but...
Here's the result:
root#debian:~# npm install phantomjs-prebuilt -g
/usr/bin/phantomjs -> /usr/lib/node_modules/phantomjs-prebuilt/bin/phantomjs
> phantomjs-prebuilt#2.1.14 install /usr/lib/node_modules/phantomjs-prebuilt
> node install.js
Considering PhantomJS found at /usr/bin/phantomjs
Looks like an `npm install -g`
Could not link global install, skipping...
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
[========================================] 100%
Received 22866K total.
Extracting tar contents (via spawned process)
Removing /usr/lib/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-
x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64 -> /usr/lib/node_modules/phantomjs-prebuilt/lib/phantom
Phantom installation failed { Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64' -> '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom'
errno: -13,
code: 'EACCES',
syscall: 'link',
path: '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64',
dest: '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom' } Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64' -> '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt#2.1.14 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt#2.1.14 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-30T23_33_57_117Z-debug.log
If I'm reading it right, it seems odd that it would download the tarball to /tmp, extract the tarball and then create a symlink to the /tmp file(s) in /usr/lib/node_modules.
Am I just doing it wrong? Other npm packages seem ok:
root#debian:~# npm install -g grunt-cli
/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli#1.2.0
added 16 packages in 1.511s
In case it matters:
root#debian:~# node -v
v8.1.2
root#debian:~# npm -v
5.0.3