How to turn off yarn#2 PnP? - yarnpkg

I am using yarn 2.0.0-rc.27 + workspaces + typescript and I want to turn PnP off and use node_modules again. I tried it with following setting in package.json:
"installConfig": {
"pnp": false
},
But yarn uses PnP mode every time. Is there any option to turn it off?

I ran into a bunch of issues with Yarn 2 as well using same stack. Solution is to create a .yarnrc.yml file with the following line:
nodeLinker: node-modules

Sometimes it is enough to run yarn unplug [problem package name] to get it working again with pnp mode.
For instance in case of next.js v12 pnp mode started to not work again (it worked with v10/v11) and the solution was to simply yarn unplug next -- it remembers that you did it by adding a new dependenciesMeta entry into the package.json file.

Related

Substrate - interacting with node issue

I am creating my first substrate chain (online tutorial).
Installed node.js and yarn - and attempting to start node in development mode <./target/debug/node-template --dev --tmp>,
when I run code keep getting error -
no such file or directory...
Obviously, I am doing something wrong, and would like to know how to solve this issue?
I can think of two possible scenarios as to why you encountered the said issue:
Since ./target/debug/node-template is a relative path, you have to be on the ditectory where the target folder is located in
Build your node-template using cargo build
Thanks for your reply.
I have built and compiled the Node Template [substrate-node-template] using [cargo build] ...
I checked the folder [substrate-front-end-template] to ensure that [yarn] and [node.js] are installed:
versions installed - yarn 1.22.5 / node 12.18.4
In [substrate-front-end-template] directory I run following code:
./target/debug/node-template --dev --tmp
Receive error 'is not recognized as the name of a cmdlet function......' –
Is the target folder located where I have installed yarn and node.js?

Yarn - There appears to be trouble with your network connection. Retrying

I have been trying to do the quickstart guide for react native, but kept getting this error
There appears to be trouble with your network connection. Retrying...
My connection works just fine.
This happens when your network is too slow or the package being installed is too large, and Yarn just assumes it's a network problem.
Try increasing Yarn network timeout:
yarn add <yourPackage> --network-timeout 100000
Deleting the yarn.lock file and rerunning "yarn install" worked for me.
I got this issue because I was working within my company internal network and proxy needed to be set.
$ yarn config set proxy http://my_company_proxy_url:port
$ yarn config set https-proxy http://localhost:3128
example $ yarn config set https-proxy http://proxy.abc.com:8080
Simple working solution (right way of doing it):
Looks like yarn was trying to connect via a proxy. The following worked for me:
npm config rm proxy
npm config rm https-proxy
Source
Turning off "real time protection" with windows defender fixed it for me.
Sucks but it appears the checks are too much for yarn to handle.
Could be that your network speed is too slow and timeout is relatively short, you can set yarn install --network-timeout=30000
If you still have the error, could be solved by proxy, vim ~/.yarnrc and add useful proxy setting.
yarn config set network-timeout 600000 -g
Often, your error is caused by hitting the network connection time limit, and yarn simply reports there is "trouble with your network connection".
The line of code at the top of my answer sets the global yarn network timeout to 10 minutes.
Having a long network timeout is probably okay, because yarn uses caches and if it's big and you don't have it, you probably want it to just go ahead and take the time to download.
Could be a proxy issue. Run the command below to delete the proxy.
yarn config delete proxy
The following helped me
yarn config delete https-proxy
yarn config delete proxy
they set your https-proxy and proxy values to undefined. My https-proxy was set to localhost. Check that proxy and https-proxy config values are undefined by using the following
yarn config get https-proxy
yarn config get proxy
The large package involved often can be Material Design Icons.
Check if you make use of the Material Design Fonts material-design-icons in your package.json and remove it!
material-design-icons is too big to handle and you should only use material-design-icons-fonts if you only need them.
https://medium.com/#henkjan_47362/just-a-short-notice-for-whomever-is-searching-for-hours-like-i-did-a741d0cd167b
Turn off or disable your antivirus before run this command. I am also facing same issue than i disable quick heal antivirus and it is works.
create-react-app my-app
When I want to use yarn I have above error, but there is not any error with npm, for this situation you can install react project from npm
npx create-react-app app --use-npm
Deleting the yarn-lock file, doing a yarn cache clean and then a yarn solved my issue
npm install
worked for me (but my project was built with yarn)
Got the exact issue when trying yarn install
yarn install --network-timeout 100000
Just using this didn't solve my problem. I had to install only ~5 packages at a time. So I ran yarn install multiple times with only few dependencies in the package.json at a time.
Hope this helpful
In short, this is caused when yarn is having network problems and is unable to reach the registry. This can be for any number of reasons, but in all cases, the error is the same, so you might need to try a bunch of different solutions.
Reason 1: Outdated Proxy Settings
This will throw the "network connection" error if you are connected to a network that uses a proxy and you did not update yarn configs with the correct proxy setting.
You can start running the below commands to check what the current proxy configs are set to:
yarn config get https-proxy
yarn config get proxy
If the proxy URLs returned are not what you expect, you just need to run the following commands to set the correct ones:
yarn config set https-proxy <proxy-url>
yarn config set proxy <proxy-url>
Similarly, if you have previously set up the proxy on yarn but are no longer using a network connection that needs a proxy. In this case, you just need to do the opposite and delete the proxy config:
yarn config delete https-proxy
yarn config delete proxy
Reason 2: Incorrect Domain name resolution
This will throw the "network connection" error if for whatever reason your machine cannot resolve your yarn registry URL to the correct IP-address. This would usually only happen if you (or your organization) are using an in-house package registry and the ip-address to the registry changes.
In this case, the issue is not with yarn but rather with your machine. You can solve this by updating your hosts file (for mac users, this should be found in '/etc/hosts') with the correct values, by adding a mapping as follows:
<ip-address> <registry-base-url>
example:
10.0.0.1 artifactory.my.fancy.organiza.co.za
Adding option --network=host was the solution in my case.
docker build --network=host --progress=plain .
I encountered this error while attempting yarn outdated. In my case, a few of the packages in my project were hosted in a private registry within the company network. I didn't realize my VPN was disconnected so it was initially confusing to see the error message whilst I was still able to browse the web.
It becomes quite obvious for those patient enough to wait out all five retry attempts. I, however, ctrl-c'd after three attempts... 😒
In my case I found a reference to a defunct registry in my ~/.yarnrc file
When I removed that the error went away
This happened in my case trying to run yarn install.
My project is a set of many sub-projects.
After a couple of retries, it showed a socket-timeout error log:
error An unexpected error occurred: "https://<myregitry>/directory/-/subProject1-1.0.2.tgz: ESOCKETTIMEDOUT".
I cloned subProject1 separately, did yarn install on it and linked it with main project.
I was able to continue with my command on main project after that.
Once done, I unlinked the subProject1 and did a final yarn install --force which was success.
I got this error while trying to run yarn install - i use WSL with ubuntu distro, the following command fixed it,
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
This may be a late answer but here are some possible reasons:
If you are behind a proxy you may need to configure .npmrc if you are using npm or .yarnrc if you are using yarn
If proxy is well setup, you may need remove yarn.lock or package-lock.json and re-run npm i or yarn
If you are working within a docker environment or elsewhere that might need a different approach where you are not modifying the installation process, try adding a file named .yarnrc in the root of the project with the problem (where your package.json resides) and in that file write:
network-timeout 600000
Docker will still run without modifying the docker-compose.yml file and you get the timeout solution.
I faced the same issue but adding VS Code to the Firewall Exception List has solved my issue.
I got the same issue but my case is totally different. I am on Linux, and I get this error because I had a service nginx status off.

Google cloud app engine - How to edit code using SSH and debug-mode

I am trying to debug an application I have deployed to google cloud app engine. Reading the docs, I figured out that in order to do so I have to enter the debug mode using
gcloud app --project [Project ID] instances enable-debug
afterwards I am able to SSH into my instance and access root. Now I would like to edit some of the files. However, trying to use vim or nano does not seem to work.
Is there a way to edit those files without re-deploying the entire app?
Once you SSH into the App Engine instance and open a shell into the Docker container, you'll need to download the package list before installing nano or vim:
apt-get update && apt-get install nano
Then you can edit your app's files (which are in /app):
nano composer.json
The deployed app runs live code. It is not generally feasible to edit it. Moreover, changes made to the running container are not permanent; in fact they and are lost at the first re-start.
You may find some information on the Debugging an Instance page.
Unrelated to the above, an actual command-line editor is offered in the cloud shell.

Gradle :Could not create service of type FileHasher

I'm using Gradle to build a java project.
When I run any task (assemble, test).
I get randomly an error :
Could not create service of type FileHasher using
GradleUserHomeScopeServices.createCachingFileHasher()
Did any one had the same issue before?
Gradle V:3.5
java 8
I'm using the java plugin.
Thanks,
I was facing the same because I accidentally hit ctrl+z during build, and then the error was the same as yours.
I tried to remove the lock file but it didn't solve the problem.
Then I find all the process related to gradle by ps aux | grep gradle, and then kill -9 <pid> them all. The build backed to normal.
In your terminal type this:
./gradlew build
and the outcome would be:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHasher().
> Timeout waiting to lock file hash cache (/Users/zra/.gradle/caches/4.1-rc-1/fileHashes). It is currently in use by another Gradle instance.
Owner PID: 17571
Our PID: 26055
Owner Operation:
Our operation:
Lock file: /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock
now do:
rm /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock
and build again.
P.S replace xxx with whatever username you've.
What worked for me was removing the lock file like suggested in the answer above: rm /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock and also killing the IDLE processes by running the command
./gradlew --status
It generates a list of gradle processes with status like
PID STATUS INFO
23580 IDLE 5.2.1
23860 IDLE 5.2.1
19058 STOPPED (stop command received)
Then kill one of the idle processes by kill <PID> and run the gradle build again.
One simple cause is that gradle daemon is not started with the same environment variable.
I had the same issue while changing the gradle user home.
Simply stop the daemon:
gradle --stop
change the ownership of .gradle/ using the following command:
sudo chown -R <USERNAME> .gradle/
I couldn't find this info elsewhere, posting in case it helps someone:
I had the same issue while running Android Studio on ChromeOS (on Chromebook).
I had shared a Google Drive folder with Linux (by selecting a folder, right-clicking and selecting Share with Linux) and created my project there. Build failed with this error, and removing the lock file did nothing for me.
Problem was resolved for me by re-creating the project under a 'Linux folder'.
If the OS is Windows.
Try this: gradlew build
Find de PID Process
And in CMD execute this command
TASKKILL /F /PID #PID
In my case, I was keeping the entire project in a folder managed by Google Drive Stream. Since that's a very rudimentary filesystem, Android Studio (or Git or Gradle, I can't tell which) was trying to do something on the FS that Google Drive Stream doesn't allow.
I simply moved the project onto my local drive and that fixed it!
I got the same error when I tried to execute ./gradlew from WSL2 ubuntu.
As suggested by #user16115, I stopped the running gradle in my host machine (windows machine) by issuing command gradlew.bat --stop.
After stopping the gradle in my host machine, I issued the same command ./gradlew in WSL2, gradle worked as expected.
ps: I have mounted my C:/ drive into WSL2 ubuntu.
This was same problem for me before some days and now only it's your or the user reading this solution.
Uninstall full android studio (means- 'after uninstall from control panel, delete folders of Android Studio,')
folders to be deleted:
C:\Program Files -> Android,
C:\Users{user folder name} -> .android & .gradle & {other folders related to Android Studio}
Reinstall form it's .exe and make sure your PC in connected with internet and with proper speed.
Download all SDK files as mention in that and keep downloading in Android Studio only. [do not download form other source- otherwise it will show errors, be careful]
Click on new project and select empty project and give the name and click on finish.
you will redirect to another window and than the main thing starts that is installation of GRADLE so for this you should have high connectivity of internet and that it will download automatically and and and now your are ready to go.
I had the same issue and the solution was to login with the correct user and then run gradle. I was logged in with a user that didn't had rights to run the tasks.
I just moved a project from Download folder (on Mac) to another one
If you try to build an inner project - try to go to root project and call
./gradlew <moduleName>:<command>
The easiest solution in my case wast to run
In case of linux
sudo ./gradlew bundleRelease
if windows then login with the user who has highest privileges.
Because this error occurred due to insufficient permissions

It is currently in use by another Gradle instance

I want to do some basic functions. I'm running/building it in command line. I am referring User guide. And, doing some simple tasks.
When I start to run simple tasks, it was build successfully. But, After some times, it is showing "It is currently in use by another Gradle instance" and becomes BUILD FAILED. I'm using a terminal for run the task. I didn't run anything at that time.
If I closed the terminal which generate the error, this problem would be solved. But, I know that it is not the solution for that.
Why is this error coming frequently?
How to solve it?
And, Please refer any link to improve my knowledge on Gradle Build system in Android.
Remove the lock files in the gradle cache by executing something like this:
find ~/.gradle -type f -name "*.lock" -delete
Sometimes fast way comes in a non-elegant deal, there we go:
Find first the # of all gradle process running on
ps -A | grep gradle
After that, get the IDs, Kill 'em all one by one
sudo kill -9 <process ID>
Now you're good ;-)
I was stuck with this error and had to blow away the contents of my user's .gradle/caches/ folder and the contents of my project's .gradle/ folder to get going again.
Not sure what caused it, possibly a failed build that kept these files in a locked state?
gradlew --stop
I had a similar error, running the above command worked for me.
For Windows machine:
Open Task Manager(Ctrl-Alt-Delete and check Process)
-> If you run two instance of android studio, Close One (End Task)
-> Then close OpenJDK Platform Binary
-> Gradle sync now on AndroidStudio and it will work now
Just kill java.exe process fix my problem.
-- Edit --
if not fixed then:
kill OpenJdkPlatform proccess.
if not fixed then:
remove all ".lock" file from .gradle directory and sub directories (windows: C:\Users\Username\.gradle).
if not fixed then:
rename or delete .gradle directory and try again.
That Gradle failure message is usually followed by the relevant process IDs, so it would be
Gradle sync failed: Timeout waiting to lock daemon addresses registry [...].
It is currently in use by another Gradle instance.
Owner PID: 1234
Our PID: 5678
Owner Operation: ...
In order to unlock, just kill the owner process:
sudo kill -9 1234
For MAC machines
Please open the "Activity Monitor" and select the "memory" option and force quiet the Android studio and other running java processes, it will solve this issue.
sometimes you need to run this code a few times after each build error
for me it takes two times first i get lock error I run this code then again i get the lock error for another file so I run the code again and at the end it works properly.
find ~/.gradle -type f -name "*.lock" -delete
This may be happening because there is more than just once instance of Android Studio.
I was facing the same issue in my project but I resolved this by invalidating the project, so follow these steps in the android studio
File -> Invalidate Caches / Restart...
Android studio will restart and your problem should be fixed.
I could be late but look like quick and efficient solution.
Execute following steps.
Execute ps -ef | grep gradle
Open terminal and move to ~/.gradle/caches path
Execute find ~/.gradle -type f -name "*.lock" | while read f; do rm $f; done
Delete .gradle and .idea folder from Android studio.
It's done.
Having the same issue on a Mac, none of the above worked for me. What worked , though, was opening the Activity Monitor and closing a running java process. I also noticed that an .hprof file was generated, which I deleted. After that, I ran my project and it worked.
I had the same issue on mac:
take care, that your project is NOT on an external hard disk. The location of your project must be on the hard disk with your operating system.
(Building an Ionic app)
press CTRL + SHIFT + ESC to open task manager now find OpenJDK and kill it goto where the error is pointing to like
D:\.gradle\daemon\4.10.1\registry.bin.lock
delete the file and resynce and you're good to go.
For Windows OS:
I figured it had something to do with a lock file so i simply went to .gradle\buildOutputCleanup in the project folder and deleted the cache.properties.lock file and rebuilt the project. It was working perfectly.
Along with the top answers here, you need to figure out why the gradle processes exit without releasing the locks to fix it permanently.
In my case, I did all *.lock file deletions and Android Studio's Invalidate Cache option. But the problem kept coming back.
Running gradlew manually in the terminal showed me that gradle processes prematurely exit when the JVM heap space is exhausted. This answer helped to fix it.
./gradlew build #to detect what crashes gradle processes
./gradlew --stop #to stop any running gradle processes
After fixing the problem (eg: heap exhausted)
find .gradle/ -type f -name "*.lock" -delete #delete lock files
./gradlew build #Try building the project
On windows . In Android Studio open Terminal window (used to start in project's root folder) and tipe in
.\gradlew --stop
mine responded:
Welcome to Gradle 7.3.3!
Here are the highlights of this release:
- Easily declare new test suites in Java projects
- Support for Java 17
- Support for Scala 3
For more details see https://docs.gradle.org/7.3.3/release-notes.html
Stopping Daemon(s)
1 Daemon stopped
And now it plays ok with builds and runs as previously
I was too stuck with the same thing. But it was sorted soon. Just delete the file:
D:\.gradle\daemon\6.1.1\registry.bin.lock
also, I've ended OpenJDK from task manager. Idk it helped or not but both of them solved the problem.
Just delete yours .gradle folder inside android folder
If it is not available in your File Explorer(WINDOWS) or Finder(MAC)
For Windows :
go to view option and check show hidden files
For Mac
just press cmd + shift + .
Now run your app.
It was not necessary for me to remove any files to fix this error.
The issue I had is that Gradle instances had hung and were 6 command prompt entries in my task list that were spawned by Java.
Forcing the command prompt instances to close allowed me to continue work as usual.
Its Work for me for
Problem:-
"Error:Timeout waiting to lock jars It is currently in use by another Gradle instance. Owner PID: 6896 Our PID: 5048 Owner Operation: Our operation: Lock"
Solution:-
close the Android Studio and Open Task manager and end the process java.exe
open the derectory ....gradle\caches.
Delete the jar2.lock file.
Open android Studion and clean the project.
Have tried all this answers, including kill java process, delete .gradle in HOME_DIR and in project dir, restarted Android Studio, and even restarted OS.
It started to work normally only after I launched gradle sync.
Very simple solution:
no need to kill Android Studio , just Kill OpenJdkPlatform process,
then delete the .lock file located in:
rootProject/.gradle/<version>/taskHistory
While killing the process and/or removing the lock file works, Gradle should be able to handle this on its own, solving the problem permanently. This problem report hints at the solution: Gradle cannot communicate with the gradle service.
Have a look at your local network firewall. In my case,
allowing outbound traffic from 127.0.0.1 to 127.0.0.1,
sudo iptables -A OUTPUT -p udp -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
allowing incoming traffic from 127.0.0.1
sudo iptables -A INPUT -s 127.0.0.1 -p udp -j ACCEPT
solved the issue. A discussion of a similar problem at github.
And, Please refer any link to improve my knowledge on Gradle Build system in Android.
The udacity gradle course, if you have some time.
open terminal and move to project path then run depending on the operation system:
gradlew clean or ./gradlew clean
I had same problem and i did two steps and it became solved.
My JDK was not installed on Mac (i forgot to install) i installed it.
I deleted all items from caches folder located in this path /Users/icon_developer/.gradle/ and rebuilt the project.
It worked!
For Windows Users:
That Gradle failure message is usually followed by the relevant process IDs, so it would be
Gradle sync failed: Timeout waiting to lock daemon addresses registry [...].
It is currently in use by another Gradle instance.
Owner PID: 8080
Our PID: 89765
Owner Operation: ...
In order to unlock, just kill the owner process:
taskkill /PID 8080 /F
taskkill /PID 89765 /F
For Mac users on first Gradle sync
I had the same issue when cloning from GitLab using IntelliJ.
In fact, as mentioned here : https://stackoverflow.com/a/53269914/2231299
you need to specify an internal hard disk.
So here were the steps in my case:
• Clone locally
• Wait for 1st gradle syncing to perform
• move directory to external hard disk
• reopen project at new location, and then gradle should work fine, even on external hard disk.
Comments:
Don't be afraid to re-commit if it looks like the files have some changes. It might just be indentation or line breaks issues, since your external disk might have a different format than your original mac disk.
In my case the culprit was restrictive firewall, part of the antivirus system.
According to the https://discuss.gradle.org/t/timeout-waiting-to-lock-file-hash-cache/21961/2 and https://github.com/elastic/elasticsearch/issues/50954#issuecomment-576772154, gradle-issue-8750, gradle server is keeping the lock and releases it on request of other gradle process. The communication goes over UDP socket on localhost. Thus if there is a firewall blocking this communication, gradle keeps file locks and other gradle processes cannot continue.
Try disabling AV / firewall to see if problem vanishes. Then run gradle as following to get better insight what is going on.
gradle --debug --no-daemon
The debug log shows owner of the lock, if the problem persists, kill the owner of the lock.
2021-05-20T19:32:41.105+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] The file lock is held by a different Gradle process (pid: 67494, lockId: 628651820260732672). Pinged owner at port 58442
2021-05-20T19:32:42.330+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] The file lock is held by a different Gradle process (pid: 67494, lockId: 628651820260732672). Pinged owner at port 58442
Then kill -9 67494 terminates the owner and releases the lock.
Otherwise after a while gradle terminates with an error (stating here so it is easy to find):
* What went wrong:
Gradle could not start your build.
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeServices.createResourceSnapshotterCacheService().
> Timeout waiting to lock file hash cache (/Users/myusername/.gradle/caches/6.9/fileHashes). It is currently in use by another Gradle instance.
Owner PID: 67494
Our PID: 68313
Owner Operation:
Our operation:
Lock file: /Users/myusername/.gradle/caches/6.9/fileHashes/fileHashes.lock

Resources