Laravel vapor github action throws permission error - laravel

I'm trying to use Github Actions to deploy to vapor. I'm using the action as decribed on https://docs.vapor.build/1.0/projects/deployments.html#deploying-from-ci.
name: Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout#v2
- name: Setup PHP
uses: shivammathur/setup-php#v2
with:
php-version: 8.0
tools: composer:v2
coverage: none
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Require Vapor CLI
run: composer global require laravel/vapor-cli
- name: Deploy Environment
run: vapor deploy
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
The github action keeps failing due to this error:
Error Output:
================
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git#github.com/jawid-h/protobuf
.js.git
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address '140.82
.113.4' to the list of known hosts.
npm ERR! git#github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
I have already tried passing the GITHUB_TOKEN, but that somehow doesn't work.

This is a ssh key error. You are not using the same ssh key as the one you imported in Github or it is not accessible in some way. You need to check ~/.ssh/id_?sa or manually specify another file.
Or you could also switch to anonymous https protocol by changing the repository URL if you don't need write access by replacing:
ssh://git#github.com/jawid-h/protobuf.js.git
with
https://github.com/jawid-h/protobuf.js.git

In my case I'm use GITLAB platform and I get the same error. I solve the issue with delete 'package-lock.json' and run a new one 'npm install'.
On package-lock.json, you find this line "lockfileVersion".
The version before solve issue:
"lockfileVersion": 2,
The version after solve issue:
"lockfileVersion": 1,

Related

Azure DevOps NPM task returns 403 while bash task succeeds

I'm trying to switch from using Azure DevOps Bash task to NPM task and when running the NPM task it fails with 403 while with Bash task it works.
This is the bash task that is working:
- task: Bash#3
displayName: 'npm ci'
target:
commands: any
inputs:
targetType: 'inline'
script: 'npm ci'
workingDirectory: './apps/${{ parameters.appName }}'
and this is the npm task that I'm getting an error for:
- task: Npm#1
displayName: 'npm ci'
target:
commands: any
inputs:
command: 'ci'
workingDir: './apps/${{ parameters.appName }}'
This is the complete error I'm getting:
npm ERR! code E403
npm ERR! 403 403 Forbidden - GET https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/AzDevOps_azpcontainer/.npm/_logs/2022-11-20T14_20_22_151Z-debug-0.log
##[warning]Couldn't find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1
Finishing: npm ci
In general I wanted to know what's the difference between these two tasks? Aren't they supposed to be identical? And what could be causing the different result?
You should create a Azure DevOps Service connection for npm repositories and specifically with the credentials you use for npmjs.
The NPM task for Azure DevOps can use the Service Connection as specified in the docs for the NPM task

Cypress doesn't run after upgradinig

I had Cypress package version: 7.1.0.
I tried to upgrade version: 9.6.1.
Got following error and npx cypress open is giving error.
Need suggestion please.
PS C:\Users\MushfiquaZaman\OneDrive - BAFS\Documents\CypressTesting\Project1> npm install cypress#9.6.1
cypress#9.6.1 postinstall C:\Users\MushfiquaZaman\OneDrive - BAFS\Documents\CypressTesting\Project1\node_modules\cypress
node index.js --exec install
Installing Cypress (version: 9.6.1)
The Cypress App could not be downloaded.
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypre
ss.io/proxy-configuration
Otherwise, please check network connectivity and try again:
URL: https://download.cypress.io/desktop/9.6.1?platform=win32&arch=x64
Error: unable to get local issuer certificate
Platform: win32-x64 (10.0.19043)
Cypress Version: 9.6.1
npm WARN Project1#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress#9.6.1 postinstall: node index.js --exec install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress#9.6.1 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! C:\Users\MushfiquaZaman\AppData\Roaming\npm-cache_logs\2022-05-13T19_11_23_404Z-debug.log
PS C:\Users\MushfiquaZaman\OneDrive - BAFS\Documents\CypressTesting\Project1>
Session contents restored from 5/13/2022 at 2:11:34 PM
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Loading personal and system profiles took 1859ms.
PS C:\Users\MushfiquaZaman\OneDrive - BAFS\Documents\CypressTesting\Project1> npx cypress open
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:\Users\MushfiquaZaman\OneDrive - BAFS\Documents\CypressTesting\Project1\node_modules\cypress\bin\cypress'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Please notice that log includes: "The Cypress App could not be downloaded.". Please download Cypress archive without using npm, unpack archive to cache ( C:\Users\your_username\AppData\Local\Cypress\Cache\9.6.1 ) then install it as previously: npm install cypress#9.6.1 .
It's because you are installing into a "OneDrive" location which is a remote location to where your cache resides (hence the complaint about a workplace proxy).
Try installing to a local path and copying the project up to OneDrive, which I presume is what you did for v7.1.0.

Running Vapor from Homestead failds

I installed Vapor in a brand new Laravel up. When I try to run 'vapor deploy production' I get this error:
Running Command: npm ci && npm run prod && rm -rf node_modules
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm#5 or later to generate it, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2019-10-23T21_24_09_128Z-debug.log
In Process.php line 254:
The command "npm ci && npm run prod && rm -rf node_modules" failed.
Exit Code: 1(General error)
Working directory: /home/vagrant/code/sales2/.vapor/build/app
Output:
================
Error Output:
================
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVers
ion >= 1. Run an install with npm#5 or later to generate it, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2019-10-23T21_24_09_128Z-debug.log
I sucessfully installed vapor. Created a new project and left the domain setting at default.
You didn't specify what your host operating system was, but I assume it's windows, when you ran "vagrant up" did you do so as administrator?
That said, this is an issue with npm and not Vapor. I'd running the "npm ci && npm run prod && rm -rf node_modules" command ssh'd into your vagrant console and troubleshoot from there.
You may not have configured the node package manager for this project. From your computer and not the homestead if you are using, run this command
<project directory>: npm install
This will create the necessary file.

Can't find package.json in directory in CircleCI build

I have a repo that contains two subprojects. Just for completeness a frontend project and a firebase cloud-function project (both using separate package.jsons). Now for this project, I want to start two jobs concurrently. But I can't get the setup done with CircleCI. I don't have any cache-configuration.
project structure
-creepy-stories
-.circleci
-cloud-functions
-functions
package.json
-frontend
package.json
config.yml
version: 2.1
jobs:
cloud-functions:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories/cloud-functions/functions
steps:
- checkout
- run: npm install
- run: npm run lint
- run: npm run build
frontend:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories/frontend
steps:
- checkout
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test:coverage
workflows:
version: 2
cloud-functions_and_frontend:
jobs:
- cloud-functions
- frontend
So now my I guess my problem is the environment cant find my package.json file. The error that is printed looks as follows:
npm run lint
#!/bin/bash -eo pipefail
npm run lint
npm ERR! path /home/circleci/creepy-stories/frontend/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/circleci/creepy-stories/frontend/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2019-04-20T13_08_45_252Z-debug.log
Exited with code 254
I don't know if it is right to set the working directory twice in my configuration, but it is at least set in two diff. jobs.
Update
I managed to get it work if I checkout the root of the Project and then cd to the needed folder and execute the scripts. But this isn't really DRY (don't repeat yourself) maybe some of you have a better solution:
version: 2.1
jobs:
cloud-functions:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories
steps:
- checkout
- run: cd cloud-functions/functions && npm install
- run: cd cloud-functions/functions && npm run lint
- run: cd cloud-functions/functions && npm run build
web:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories
steps:
- checkout
- run: cd web && npm install
- run: cd web && npm run lint
- run: cd web && npm run build
- run: cd web && npm run test:coverage
workflows:
version: 2
concurrently:
jobs:
- cloud-functions
- web
When you checkout, you automatically copy the root of the git repository into the current working directory. If you want your working directory to be a sub-directory of the root, you need to give the checkout step a path that copies the files into a parent of the working directory.
Example:
working_directory: ~/creepy-stories/cloud-functions
steps:
- checkout:
path: ~/creepy-stories
Link to the documentation: https://circleci.com/docs/2.0/configuration-reference/#checkout
I think you've got an added directory in the way.
You should add an extra run to your CircleCi frontend task that does a pwd and then a ls -la.
You'll probably find that the checkout has ended up inside a directory with the same name as your repo.
Edit to answer followup question:
If i remember correctly, the checkout command, always put it in the root of the server, so you can update the working directory to accommodate that. Like so
working_directory: ~/creepy-stories/web
steps:
- checkout
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test:coverage

Getting error "EACCES: permission denied" when i install cypress

When i try to install cypress using this commnad:
sudo npm install cypress
or
sudo npm install -g cypress
It is giving me this error:
Error: EACCES: permission denied, open '/Users/humac/node_modules/cypress/cypress.zip'
Workaround: sudo npm install --unsafe-perm=true --allow-root cypress
In my case cypress had trouble accessing /root/.cache/Cypress upon npm install:
EACCES: permission denied, mkdir '/root/.cache/Cypress'
I found a relevant issue and ended up setting a custom cache dir:
export CYPRESS_CACHE_FOLDER=/app/.cache
npm install
Try using yarn package manager or downgrading npm to version 7.
For me it worked correctly.
I'm using Jenkins in an alpine linux container with node 16.
stage('Prepare-build') {
steps {
sh 'node --version'
sh 'npm --version'
sh 'ls -p'
sh 'git config --global --add safe.directory "*"'
sh 'yarn install'
}
}
The error I was getting is the following:
npm ERR! code 1
npm ERR! path /home/jenkins/agent/workspace/project/app/project-web-manager/node_modules/cypress
npm ERR! command failed
npm ERR! command sh /tmp/postinstall-716e113e.sh
npm ERR! Cypress cannot write to the cache directory due to file permissions
npm ERR!
npm ERR! See discussion and possible solutions at
npm ERR! https://github.com/cypress-io/cypress/issues/1281
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Failed to access /root/.cache/Cypress:
npm ERR!
npm ERR! EACCES: permission denied, mkdir '/root/.cache/Cypress'
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Platform: linux-x64 (Alpine Linux - 3.16.1)
npm ERR! Cypress Version: 10.6.0
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-08-18T17_09_27_887Z-debug-0.log
In my same case export the environment variable cypress cache folder did not work as expected, the error was even made mentioned above.
export CYPRESS_CACHE_FOLDER="/home/jenkins/agent/workspace/project/app/.cache"
After clearing my Cypress cache folder with cypress clear cache I ran into this issue as well.
This is what I did:
sudo rm -rf the Cypress folder in your .cache directory
For me I also deleted the Cypress folder in node_modules
Cleaned cache with npm cache clean --force
Installed Cypress with npm install cypress --save-dev
Hope this helps!
In my case I had issues running Cypress on Mac
An unexpected error occurred while verifying the Cypress executable.
----------
Error: EACCES: permission denied, open '/Users/me/Library/Caches/Cypress/9.7.0/binary_state.json'
----------
Platform: darwin-x64 (22.2.0)
Cypress Version: 9.7.0
The easiest think to do is to locate the folder within Finder app, and for both "Cypress" and "9.7.0" folder and adjust the permissions for "everyone" and "staff" to "Read & Write".
Note: You must click on the lock icon and use your mac admin/system password to change the permissions.

Resources