Yarn build fails with ENOENT: no such file or directory - yarnpkg

We automated some of our react applications using Jenkins and Yarn. However, build is successful for few branches and fails for few
I am finding it to bit difficult to understand. Example of failed build is provided below
yarn cache
Removed yarn cache directories both 'system cache' and 'jenkins cache' (yarn cache clean inside jenkins job)
[root#jenkins ~]# ls -l /usr/local/share/.cache
ls: cannot access '/usr/local/share/.cache': No such file or directory
Error Message
error https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/var/lib/jenkins/.cache/yarn/v6/npm-typescript-4.5.4-a17d3a0263bf5c8723b9c52f43c5084edf13c2e8-
package.json
"typescript": "^4.1.2"
After removing cache folders and rebuilding resulted in following folders being created
Jenkins cache (/var/lib/jenkins/.cache/yarn/v6)
drwxr-xr-x 3 jenkins jenkins 26 Jan 5 04:44 npm-typescript-4.0.3-153bbd468ef07725c1df9c77e8b453f8d36abba5-integrity
drwxr-xr-x 3 jenkins jenkins 26 Jan 5 04:44 npm-typescript-4.5.4-a17d3a0263bf5c8723b9c52f43c5084edf13c2e8-integrity
I would like to understand how and why npm-typescript-4.0.3 and npm-typescript-4.5.4 directories were created in .cache folder when a different version "typescript": "^4.1.2" is mentioned in package.json

Related

Bitbucket Pipeline doesn't show the full output of Yarn build

I have a bitbucket pipeline with a yarn build command. The problem is that the output always misses the last lines:
+ yarn build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
It is suppose to have more lines after File sizes after gzip:.
My bitbucket-pipelines.yml:
image: node:latest
pipelines:
branches:
staging:
steps:
- step:
name: Build
caches:
- node
script:
- yarn install
- yarn build
The biggest issue is when yarn build errors. Because I don't see the last lines, I can't tell why it failed. When this happens, I have to manually run yarn build on my local machine to see the full logs, which is not the best solution.
When I run the same yarn build command on my machine, I get the full logs:
❯ yarn build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
383.56 kB build/static/js/main.a23388a2.js
13.39 kB build/static/css/main.06459f93.css
1.79 kB build/static/js/787.44808443.chunk.js
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
yarn global add serve
serve -s build
Find out more about deployment here:
https://cra.link/deployment
Done in 19.59s.
I found that the output is truncated on many other commands, not just yarn build. I created a simple echo "Hello, World!" that is executed remotely on a server via atlassian/ssh-run, and the "Hello, World!" message was truncated.
Solution: refresh the page.
tl;dr;
This is a three-year bug (and counting) on the BitBucket interface:
https://jira.atlassian.com/browse/BCLOUD-18574
It seems their interface doesn't work properly getting the results in real-time, but the logs are properly saved and can be retrieved by reloading the page.

docker-compose NuxtJS project permission denied when running yarn

I have a NuxtJS project that I want to run in a docker container.
Everything works as expected, the only issue is that, since I am working on windows, the yarn command is extremely slow.
I tried to fix that by excluding the node_modules and .nuxt directories from the mounted volumes:
volumes:
- .:/app
- /app/node_modules
- /app/.nuxt
Now here is the problem. The initialisation process is very fast up until it throws an error:
error An unexpected error occurred: "EACCES: permission denied, mkdir '/app/node_modules/#babel'".
I've done this in multiple projects and never had an issue.
Inside the container the folder permissions are as follows:
drwxr-xr-x 2 root root 4096 Apr 11 15:15 node_modules
Changing writing permissions inside the container obviously does not work:
chmod: changing permissions of 'node_modules/': Operation not permitted
when I changed the docker-compose file I recreated the containers so there is no issue there.
Any idea what could be wrong?

jenkins permission denied while running cd command

I am fairly new to macOS and I am trying to run a shell script through Jenkins for a maven project.
I just don't know how to give/change permission so that Jenkins can even change a directory.
Command I am trying to run:
#!/bin/bash
export JAVA_HOME=$(/usr/libexec/java_home)
export M2_HOME=/usr/local/apache-maven/apache-maven-3.5.3
export PATH=$PATH:/usr/local/apache-maven/apache-maven-3.5.3/bin
cd /Users/User1/Documents/QA_Automation/Selenium/workspace/TestProject
mvn clean install -Dtest=IOSTDMobileTest -Dwebtest.browser=Chrome
Output I am getting:
Building in workspace /Users/Shared/Jenkins/Home/workspace/Test job 2
[Test job 2] $ /bin/bash
/Users/Shared/Jenkins/tmp/jenkins1874710180338230332.sh
/Users/Shared/Jenkins/tmp/jenkins1874710180338230332.sh: line 7: cd:
/Users/User1/Documents/QA_Automation/Selenium/workspace/TestProject:Permission denied
I had the same problem with the next task:
cd /home/allex/NetBeansProjects/HelloWorld/
pwd
javac HelloWorld.java
java HelloWorld
When I executed it I got the "Permission errors like you" but in my interactive CLI I didn't have problem to access to the directory. Then I realized that the user who execute the command in Jenkins is "jenkins" who didn't have rights access to that directory by executing this command:
ls -ld /home/allex/
drwxr-x---. 87 allex allex 4096 Nov 19 08:57 /home/allex/
As you can see the user jenkins has no permissions over that directory. Then what I did was add the user jenkins to the group allex with the next command:
usermod -a -G allex jenkins
And that was all. It's working.

No such file or directory when run as service?

When i run my application from terminal sudo -u www-data ./scarga and open browser, the template file served well, everything ok. Command executed from /var/www/html/scarga.local/ directory.
When i run my application as sudo service scarga start it says: open ./resources/views/index.html: no such file or directory
File with HTTP handler: https://pastebin.com/MU7YDAWV
The scarga.service file: https://pastebin.com/eBL3jJFx
Tree of project: https://pastebin.com/rFVa8A3P
Rights for index.html file
-rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html`
Why this happens and how to solve?
Thank you!
You need to set the correct working directory in your script using WorkingDirectory= - presumably:
WorkingDirectory=/var/www/html/scarga.local

NiFi Build Errors

I'm trying to build Apache NiFi after cloning it from https://github.com/apache/nifi and it keeps failing on the tests on the nifi-standard-processors project. I opened up the output file in the surefire-reports directory and there's the below error that it can't run program "cmd" in directory /var/test, because no such file or directory exists. The first time I ran the install it didn't exist, but I created it and I still get the error message. I do a sanity check every time to make sure the directory still does exist. Does anyone have any idea what might be causing this issue? I'm only taking a very few steps to do this. They are posted below. I'm logged on as root on a CentOS Linux VM. Thanks in advance for any help.
Steps:
cd /tmp
git clone https://github.com/apache/nifi
cd nifi
mvn clean install
[main] ERROR org.apache.nifi.processors.standard.ExecuteProcess - ExecuteProcess[id=a8d6b3a3-befa-4b74-a962-330bd021ec7b] Failed to create process due to java.io.IOException: Cannot run program "cmd" (in directory "/var/test"): error=2, No such file or directory: java.io.IOException: Cannot run program "cmd" (in directory "/var/test"): error=2, No such file or directory
I believe this is due to a recent commit "solving" this ticket[1]. I actually already reopened[2] it due to failures on TravisCI and the contributor is currently working on a fix.
In order to build now, you can tell maven to "skip tests" by running the command with the proper flag: mvn clean install -Dmaven.test.skip=true
[1] https://issues.apache.org/jira/browse/NIFI-2905
[2] https://issues.apache.org/jira/browse/NIFI-2905?focusedCommentId=15603258&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15603258

Resources