Changing CAPACITOR_ANDROID_STUDIO_PATH in Arch Linux - 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.

Related

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

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.

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.

Node executable can't be found in Visual Studio Code

I'm using Visual Studio Code to (try to) debug my node.js scripts. On the moment I want to debug my index.js file, Visual Studio Code says 'Cannot find runtime 'node' on PATH. Is 'node' installed?
And the answer to this question is 'yes', because it can be found in my 'usr/local/bin' folder. And when I execute the commando 'echo $PATH' in my bash terminal, then I see this path is included (among others):
echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/{myName}/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Have also done some google searches on the issue but haven't been able to find a sound solution.
Can you please help?
Hans
For background info: I have installed Visual Studio Code via Anaconda and I'm using a Mac on 10.13.6 (MacOS Sierra).
I rather hoped there would be an answer better than the one I am about to give. For me over on Ubuntu 19.04, going through the install process for node fixed the issue; in my case, the PATH variable on my system was correct, and everything in ./.vscode/launch.json was correct. Defeated, I decided to reinstall node, and suddenly debugging worked despite the PATH being exactly the same afterwards. Never thought I would be debugging my debugger!

Can't find Git or Cordova on your path (Windows/Netbeans), Can't find GitHub under AppData/Local, FIX 2015

Error: NetBeans cannot find git or cordova on your path.
When trying to create a new Cordova Application in Netbeans.
How to fix? > THE ANSWER CAN BE FOUND BELOW :)
If anyone wants to know how to get Cordova working in Netbeans anno 2015/2016 here is the fix:
I have installed:
Git version: 2.5.1 for Windows 64 bit
Cordova version: 4.3.1 for Windows 64 bit
Node.js version: 0.12.0 for Windows 64 bit
Netbeans version: 8.0.2 x86
In Netbeans when I start a new project and select HTML5>Cordova Application then I will get this error:NetBeans cannot find git or cordova on your path.
After some searching on the good old internet, I found some pieces of information hither and thither which was correct but which didn't solve my problem. The reason for this was that it was old or slightly different than my problem. So I did the following to fix this problem:
I checked where my Cordova/npm files where and I happily found them in: C:\Users\\AppData\Roaming\npm
Next I had to find my Git.exe which FOR ME is located in: C:\Program Files\Git\bin (FOR SOME PEOPLE IT CAN BE FOUND IN: C:\Users\\AppData\Local\GitHub\PortableGit_)
Now I found out that Netbeans is using the windows PATH VARIABLES to locate git and cordova. For those who don't where to find or set the system Path Variables this website will help you find or set it: https://java.com/en/download/help/path.xml
I use windows 7 so I did this to change my path variables:"
-Select Computer from the Start menu
-Choose System Properties from the context menu
-Click Advanced system settings > Advanced tab
-Click on Environment Variables, under System Variables, find PATH, and click on it.
-In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
SO edit path and then you see like C:/apath;C:/asdas; < enter here your git path;<enter here your cordova path and save it by clicking the OK button.
Restart Netbeans and now it has to work.
:)
For those getting here and the solution from #bboni did not work - as it did for me:
Make sure everything is installed correctly by opening a command prompt (open start-menu and type cmd).
Type the following commands git --version, cordova -v and node -v.
For me it looked like this:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\JohnDoe>git --version
git version 2.8.4.windows.1
C:\Users\JohnDoe>cordova -v
6.2.0
C:\Users\JohnDoe>node -v
v4.4.5
That makes sure everything is installed correctly. If one or more commands result in an error, then it's either not installed or not added to PATH as described by #bboni.
Now open your Netbeans and go to Tools → Options → HTML/JS → Mobile Platforms and check if you can see somethink like Installed Cordova version: 6.2.0. This is to make sure Netbeans is basically able to detect Cordova.
At that point all the tutorials I found online ended. I came up with the idea to check if Netbeans' own Terminal would be able to execute the command above as well: Tools → Open in Terminal
I got an error telling me I'd need Cygwin to use the Terminal. So I installed it, restarted Netbeans, opened the Terminal, checked the commands above and they worked.
I checked Configure Cordova again - the error was gone and I could finally ran my app directly from Netbeans as I wanted to.   :)

Did I break phonegap when adjusting environment variables on Windows 7?

Installed node.js
Installed phonegap: npm install -g phonegap
Created the example app: phonegap create hello com.example.hello HelloWorld
Used the run command to test in Android: phonegap run android
What happened next is it didn't detect the Android SDK, so it asked me for build.phonegap.com account. I went ahead and created an account and entered user/pw and like magic, it created the app in the cloud. I pointed my qr code scanner to the screen and it installed on my Android phone. Cool, but...
I wanted to develop locally using the Android emulator. So I followed the instructions (http://docs.phonegap.com/en/3.0.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide) to install Android SDK, change PATH variables, etc.
When I went back to command line and cd to my phonegap root folder, suddenly "'phonegap' is not recognized as an internal or external command...'. I tried to reinstall phonegap with npm and it looks like it installs just fine again, but even when restarting cmd.exe, phonegap commands do not work.
Any ideas? Changing environment variables shouldn't affect phonegap already installed, right? The only other thing I can think is I had to install Ant and made an ANT_HOME system variable..
Apologies for the noob question. I'm sure I'm just messed up something simple here..
Figured this out. I accidentally DELETED the environment variables for node.js when I was trying to APPEND additional environment variables manually for android sdk & Ant. Since phonegap was installed as a node package, it wasn't recognized.
Better reinstall using the Msysgit and give the correct path. In my case envi variable path is as follows,
C:\Program Files\nodejs\; ->NodeJS path
F:\windows_adt\sdk\platform-tools; ->SDK Platform Tools
F:\windows_adt\sdk\tools; ->SDK Tools
C:\msysgit\bin; ->Bin Folder
C:\msysgit\git; ->git
C:\msysgit\libexec\git-core; ->git-core, if you want.
To reduce further errors use the recommended msysgit shell.

Resources