Gradle exec PATH in Android Studio doesn't match command line - android-studio

I'm running a Gradle script that needs to exec a few commands. (In my example, it's node.)
In my Terminal, node is on my PATH, so I can type node --version and it just works. My Gradle script works fine on the command line.
But when I try to run the Gradle build in Android Studio, it says:
> A problem occurred starting process 'command 'node''
Cause: error=2, No such file or directory
Unfortunately, the way this script runs on various machines, I can't be sure what the path to node will be; I need to use the PATH environment from the user's machine. (On macOS, node might be in /usr/local/bin or /opt/homebrew/bin or ~/n/bin or something else entirely.)
How do I make this work?
EDIT: To clarify, our developers will launch Android Studio via the OS launcher, e.g. by double-clicking it in Finder on macOS, or from the Start menu in Windows.

My hunch would be that the PATH in Android Studio depends on how Android Studio is started. If I start it from a Linux shell, then it uses the same PATH which is set in that shell. If you use an OS-specific launcher, then I suppose the PATH depends on what this launcher used – which may be different from the one that you set explicitly/implicitly for your shell (e.g., in a ~/.bashrc file).
I doubt that you can get this to work reliably without manually making sure on all user machines that the PATH is always set correctly for Android Studio – or that you manually make sure that all node installations end up on the “most system-wide” PATH that is available for each OS installation.

Related

visual studio code is not launching in linux even though it is in the path

visual studio code is not launching in linux even though it is in the path
I tried "code ." and expect to open the vscode for the current folder
export DISPLAY=:0 made my day
My Display was not set.It was unset while doing other debugging. reverting it make the window app launch from terminal.
DISPLAY is part of your linux serverx, usually the linux terminal doesn't support launching the window applications from terminal until the display is configured. so it is essential to make sure you have the right config for your DISPLAY arg for your serverx

Changing CAPACITOR_ANDROID_STUDIO_PATH in Arch Linux

I'm trying to set up my development environment for CapacitorJS on Arch Linux.
I followed the documentation and added
CAPACITOR_ANDROID_STUDIO_PATH=/usr/bin/android-studio
to my systems environment variables (not the project) but I'm still getting the same error
[error] Unable to launch Android Studio. Is it installed?
Attempted to open Android Studio at:
/usr/local/android-studio/bin/studio.sh
You can configure this with the CAPACITOR_ANDROID_STUDIO_PATH
environment variable.
Even though It's never pointed to /usr/local/android-studio/bin/studio.sh
I ran whereis android-studio and got android-studio: /usr/bin/android-studio, so I thought that would be the correct path, but every time I run npx cap open android it says it's trying it launch from the same path and never changes
It depends how you've installed it, for example Toolbox installs it inside the user's home directory.
nano ~/.bashrc
export CAPACITOR_ANDROID_STUDIO_PATH=~/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/bin/studio.sh
locate studio.sh might be able to find it, too.

How to open VSCode from a Windows Linux Subsystem?

I have VSCode installed on my host OS which is Windows 10 on which I have an Ubuntu Subsystem terminal (WSL) and I'm trying to open VSCode from whitin it with this command code . The problem is that the output is Command 'code' not found. How can I make this work?
Assuming you have installed VSCode in its default place, then in WSL you can do :
PATH="$PATH:/mnt/c/Users/your-user-name/AppData/Local/Programs/Microsoft VS Code"
and run code.exe .
First, try installing the Remote - WSL extension in VSCode (or the meta Remote Development extension pack, which includes the WSL work).
I doubt that's your main problem, but it could help.
Next, try running code . under PowerShell - Does that work? If not, then VSCode isn't in the Windows path. Try reinstalling it -- If it's not in the path, some other associations may not be correctly installed either. I don't recall if there's an option during installation to add or not add it to the Windows path, but if so, it could be that it was deselected during installation.
If it does launch in Windows, then obviously it's in the Windows path. By default, WSL appends the Windows path to the default path in Ubuntu during init. So (again, by default) code . should work in WSL if it is working under PowerShell.
Check your $PATH under Ubuntu (echo $PATH). Is the .../Microsoft VS Code/bin directory (wherever it is installed) in the path? If not, then WSL may not be doing its default append. Edit /etc/wsl.conf under Ubuntu and look to see if there's an [interop] section, as in:
[interop]
appendWindowsPath=false
If so, then change it to true (or, delete it entirely) to allow WSL to add the Windows path. While it's the default setting if missing, you might try adding it and setting it to true (although that shouldn't have any effect).
If that still doesn't work, then check your startup scripts (e.g. .profile, .bash_profile, .bashrc) to see if there are any modifications to the PATH which could be causing this problem.

Eclipse command not found in linux while in the eclipse folder

I downloaded the correct version of eclipse that will work on my linux machine from the website. The structure looks like this: eclipse/eclipse. I was in the eclipse folder, and I typed in eclipse in linux to start the IDE. It showed the error: eclipse command not found.
This is normal. For safety, the current directory is not part of the path used to find executables. Use ./eclipse to refer to the binary explicitly.

How Do I Get j2objc To Run With Doppl?

When I follow the instructions to get Doppl going, and I run the dopplBuild Gradle task, I get an error message about j2objc returning error code 127. What is going on?
One cause of this is not having a JDK available for command-line use on your development machine. While Android Studio can use its own JDK copy, that does not make javac and related tools available from the command line. The j2objc tool in the Doppl toolchain needs these tools available from the command line.
The simplest solution is to download and install a JDK, following whatever the normal practice is for doing so on your development machine's OS, such as downloading JDK 8 from Oracle's site and installing it. If javac runs successfully from the command line, then try running dopplBuild again and see if you get past the "error code 127" result.

Resources