In VS Code (Go extension), where do I run commands? - go

From here:
https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension
At any point in time, you can run the command Go: Current GOPATH to see the GOPATH being used by the extension.
But... WHERE do I type that command?
Is there a specific command pane I need to open or something?
(I'm on the Mac client, if that's relevant.)

Press Shift Command P, that is the command palette.
From there, type that command.
But, GOPATH is a lot less important with recent Go versions that support Go modules.

Honestly, there are some limited commands with the extension cmd+shift+p but if you want the full range of commands just open the terminal and run what you need.
If you are looking for custom tasks like building in a certain way them up can create them in vscode. https://code.visualstudio.com/docs/editor/tasks

Related

`GOTOOLDIR`'s value is set to wrong path after installing `gccgo`. How do I change it back or append path to another directory to it?

After installing gccgo the command go tool toolname stopped working due to $GOTOOLDIR being changed to one used by gccgo. It now prints go tool: no such tool "toolname" for every tool that is inside go/pkg/tool/linux_amd64/.
Can I change $GOTOOLDIR back to the old value? Or can I append the old value to it so, that go tool could look for tools in both directories?

Can't run any commands in zsh: "Command not found"

I am simply trying to set up a dev environment to code on my Windows 10 PC for use alongside my Mac when I need it.
I have installed Bash, Z shell and Node.js.
All I want to do, bare minimum, is simply:
Be able to run npm commands, etc. (npm install X)
Open files with appropriate programs from the terminal. (on Mac, I can run open index.html or atom .)
My problem: Literally no commands work. I can't run node -v, I can't do start index.html, I can't even open the current directory I'm in with explorer.
For every command, I receive an error: zsh: Command not found (:node/start/explorer/etc.)
I am guessing it has something to do with my PATH variables? I'm not sure; I'm relatively new...
Please help - I've spent four hours searching Google, Stack Overflow, page after page, but somehow can't find a solution.
Thanks.
Sounds like you have an 'eco-system challenge'... :)
Perhaps whatever tool you used to install the tools you mention:
did not do a complete install OR
requires a 'reboot' to enable all the goodies?
I suggest using a small footprint Linux OS in a VM for this type of tinkering; there are many challenges in using *nix tools on Windows - better to learn/experiment in a more Bash-friendly environment, and then, when comfy, bring the tool sets to another OS.
If you still want to give things a whirl:
locate your Bash binary
Right-click and select 'run as admin'
then use your favorite online Bash tutorial or book to explore...
:)
Dale

vscode set terminal gopath to match go.gopath

I have a Go project that I'm maintaining with vscode.
I have set the GOPATH for the project using the go.gopath setting in vscode, and this seems to work just fine for the most part.
However, when I open the integrated terminal, and type echo $GOPATH, the value shown is the value from .bashrc not the value from go.gopath.
I need the integrated terminal to respect the GOPATH that's defined by vscode so when I run commands in the terminal, everything runs properly.
I've tried setting values in terminal.integrated.shell.osx and terminal.integrated.shell.osx, but nothing seems to do what I want.
I want the intergrated terminal to understand the proper GOPATH when vscode is opened, and not have to manually set this each time I open an instance of the terminal.
I've found resources that seem like the should work, such as https://github.com/Microsoft/vscode/issues/14973 and many others, but nothing seems straight forward.
VSCode uses go.gopath i used for tools like go vet and go import... You will have to export the GOPATH on the integrate terminal with each use or set it in the bashrc... the integrate terminal is just a "clone" of the systems actual terminal. If you read the thread you provided you'll notice that what you want is a feature requests and not a current feature

where is $PATH set in xcode?

It looks like xcode's $PATH environment setting is different from my user shell environment.
Where does xcode get the $PATH setting from and what's the best way to append to the search path?
if you're writing a Run Shell Script build phase, you can just do:
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
There's some confusion in these answers, as some of them are trying to solve the $PATH for the built executable being run by Xcode. But the question is about Xcode, implying that it's about the build process itself.
For example, in a Build Phase Run Script step that runs an executable installed by Homebrew. It's not a good idea to hard-code the build process to include a path that is specific to one build machine (New macOS versions come out, new developers join the team, etc.)
The problem has multiple layers:
Changing $PATH in bashrc/zshrc/profile takes effect on shell sessions, but not in macOS applications
To solve this, you can set the PATH for applications using:
sudo launchctl config user path $PATH
You will then need to restart your machine for the change to take effect. You will need to run this again if you change your $PATH.
(This came from a comment on GitHub.)
Xcode by default does not use the system $PATH, and replaces it with its own sanitized value
This is solved by changing a User Default. This probably has some risk, since Xcode does this sanitization to ensure that its own build tools are used, and if you have executables with the same name in other places, they might be run instead. Caveat emptor!
defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO
And it looks like this gets reset on every restart of macOS, so be prepared to issue this command every time you restart.
(This part came from this answer.)
The easiest solution is to add the PATH variable in Xcode.
PATH=${PATH}:/usr/local/bin
This applies for OSX 10.7 and earlier ONLY.
XCode gets its environment variables the same way as other OS X processes, from ~/.MacOSX/environment.plist.
Check developer.apple.com/qa/qa2001/qa1067.html for details on how to set things.
In Xcode 5 you can add your PATH as a variable to either a target or the project settings.
Add a custom variable with the +sign on the top of the page
Edit the name of the variable to be PATH and add your preferred value (e.g. /usr/local/bin for a default install of homebrew.
If you are talking specifically about the executable search path environment variable named PATH, then there are a few places that it is set:
In your shell settings if it is a command line tool. Depending on your shell, this could be ~/.cshrc, ~/.profile, ~/.bash_profile, etc.
In the environment.plist file that was mentioned earlier.
If you are in a debugger, then it is whatever gdb uses. I believe that gdb will read commands from ~/.gdbinit if it exists.
XCode lets you set environment variables within the Info page for executables.
This is an update for later versions of macOS and Xcode as things have altered. This is with Xcode 11.0 and macOS 10.14
The biggest issue is that ~/.MacOSX/environment.plist does not get read now.
Build Settings
This means that if in the build you need the PATH set, e.g. for external builds and they run executables there is no simple solution. /etc/paths does not seem to be read either.
The solution is as in #GhostLyrics answer to add the PATH variable in Build Settings. However as noted in comments Xcode will not just use that value but it puts its own values before that. Also it does a straight textual substitution and so you need to also add the separator that PATH uses i.e. the : (colon). The value I have added is :opt/local/bin I also found that you can only do this for a target and not at the project level.
Run Shell Script
This is the simple case as in this answer
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
Alternatively put this change in your non login shell starter file e.g. ~/.bashrc ~/.zshrc
Running the executable
This is done in the Schema in the Run portion.
Set PATH in the environment variables as stated in answers here. Note I have not tried this and I am not certain how much of the PATH needs setting.
Xcode doesn't look at your shell path environment.
Have a look at NSProcessInfo; and do an NSLog to see what comes up.
If you want a path to apply to all graphical programs you need to set up the ~/.MacOSX/environment.plist. as described.
The recommended way to set the environmen variables are actually in /etc/paths and etc/paths.d although these are also not picked up by Xcode.
I asked about this here.
Nothing was working for me in XCode 7.
You need to set the PATH variable in XCode schemes.
Found the solution at:
Where to set environment variables for app?
Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj
Instead of opening xcode and then loading the project or double clicking on it.
I know... silly

Emacs in Windows

How do you run Emacs in Windows?
What is the best flavor of Emacs to use in Windows, and where can I download it? And where is the .emacs file located?
I use EmacsW32, it works great. EDIT: I now use regular GNU Emacs 24, see below.
See its EmacsWiki page for details.
To me, the biggest advantage is that:
it has a version of emacsclient that starts the Emacs server if no server is running (open all your files in the same Emacs window)
it includes several useful packages such as Nxml
it has a Windows installer or you can build it from sources
And concerning XEmacs, according to this post by Steve Yegge:
To summarize, I've argued that XEmacs has a much lower market share, poorer performance, more bugs, much lower stability, and at this point probably fewer features than GNU Emacs. When you add it all up, it's the weaker candidate by a large margin.
EDIT: I now use regular GNU Emacs 24. It also contains Nxml, can be installed or built from sources, and with this wrapper, the Emacs server starts if no server is running. Cheers!
Note that GNU Emacs for Windows comes with two executables to start Emacs: "emacs.exe" and "runemacs.exe". The former keeps a DOS-Prompt window in the background, while the latter does not, so when if you choose that distribution and want to create a shortcut, be sure to launch "runemacs.exe".
Carl
Easiest way to find where the user init file is:
C-h v user-init-file
Easiest way to open it is (in the scratch buffer):
(find-file user-init-file)
and hit C-j to eval
Well, I personally really like what I have been using since I started with Emacs, which is GNU Emacs. It looks like it is built for windows too. That link also answers your .emacs file question. Here is a place you can download it. You should probably get version 22.2 (the latest).
If this is your first time, I hope you enjoy it! I know I absolutely love emacs!
I run it under cygwin. That also gives me a Unix-ish environment for shelling out commands with meta-!
I use a vanilla version of emacs. In my experience, this is very stable, simple, does everything I need, and doesn't add a bunch of bloat that I don't need. The .emacs file can be placed in C:\Users\YourName if the HOME environment variable is set. This is a great way to handle it because it works on a user basis and mimics emacs behavior on Linux. You can download the zip from any gnu software repository mirror in the emacs/windows folder. You want the file that is named emacs-xx.x-bin-i686-pc-mingw32.zip.
There are some great instructions for configuring emacs for windows here. Basically, "installation" boils down to:
Download emacs from a gnu mirror at emacs/windows/emacs-version-bin-i686-pc-mingw32.zip, and extract the zip to an appropriate folder. Preferably C:\emacs to avoid spaces in the filename.
Set the HOME environment variable to C:\Users\username (or whatever you want). Make it a user-only variable (if it is username-specific). This is where your .emacs file goes.
If you want a start menu or desktop shortcut, create a shortcut to bin/runemacs.exe.
Add c:\emacs\emacs-xx.x\bin\ to your path (user or system), so that you can run it from the command line.
Also, you can consider emacs-w64 for 64bit windows systems:
emacs-w64: http://sourceforge.net/projects/emacsbinw64/
See http://www.gnu.org/software/emacs/windows/ntemacs.html. Section 2.1 describes where to get it, and section 3.5 describes where the .emacs file goes (by default, in your home directory, as specified by the HOME environment variable).
I've run both GNU emacs and Xemacs on windows. I used to use it as my primary editor, email client etc, but not it's "just" an editor.
When I recently reinstalled to Vista I installed the latest GNU version. It works fine. So does Xemacs, but it does look like GNU have got their sh*t together so Xemacs isn't as compelling anymore.
I suggest you to use development version of GNU Emacs 23, which is pretty stable and to be released relatively soon. You can get weekly binary builds from the link below.
Latest GNU Emacs as a zip archive
I have a portable version with .emacs configure ready, which setup org mode, I-do, etc. It also included org sample file. I think that is a better start point for new comers.
Basically run with runemacs.bat and everything is ready.
http://nd.edu/~gsong/portable_emacs.html
I've encountered this problem, and discovered the fault (at least in my case) to be the existence of c:\site-lisp\site-start.el, a file that was created when EmacsW32 was installed, and which was not removed when I uninstalled it. (Vanilla GNU Emacs for Windows has c:\site-lisp in its load-path, and will try to load this file, which somehow winds up triggering that error.)
Solution: removing that whole directory (c:\site-lisp) worked for me, but you should just be able to remove the site-start.el file.
The best place to start, to get an MS Windows binary for GNU Emacs is ... GNU Emacs:
http://www.gnu.org/software/emacs/
(Oh, and how did I find that URL? From the Emacs manual, node Distribution. If you have access to Emacs anywhere, that's the place to go for such information.)
On that page you will see everything you need to know about obtaining Emacs. In particular, you will find a section called Obtaining/Downloading GNU Emacs, which links to a nearby GNU mirror. Clicking that link takes you to a page of links that download all Emacs releases since release 21.
More imporantly here, on that page of links you will also see a directory link named windows. Click that to get a page of links to Emacs binaries (executables) for MS Windows. That is the page you want.
Knowing the above information can help when you need to find the page again, if you haven't bookmarked it. But here is the final URL, directly: http://mirror.anl.gov/pub/gnu/emacs/windows/
When forced to use Windows, I ...
Download "Emacs for windows", and save it in some directory (henceforth referred to as EMACS_SOMEWHERE)
Drop a .cmd file in "Startup" to map, "My Documents" to H: drive with subst, or if "My Documents" resides on a remote server, I use the "Map Network Drive" thing in Explorer to have "My Documents" named H:. Then I create an environment variable named HOME in Windows and give it the name of "H:\". Now I can drop my .emacs file in "My Documents" and it will be read by emacs when it launches.
Then I create the H:\bin directory. Then I add "H:\bin" to my Windows "Path" environment variable.
Then I create a H:\bin\emacs.cmd file. It contains one line:
#call drive:\EMACS_SOMEWHERE\emacs-23.2\bin\emacsclientw.exe --alternate-editor=c:\programs\emacs-23.2\bin\runemacs.exe -n -c %*
This is a fair bit of work, but it will enable me to run the one and same emacs from either a windows command prompt or from a cygwin command prompt, provided that /cygdrive/h/bin is added to my cygwin PATH variable. Haven't used this setup for a while but as I recall, when I call the emacs.cmd with a new file over and over, they all end up being buffers in the one and same emacs session.
There was https://bitbucket.org/Haroogan/emacs-for-windows with the latest Emacs 25, but the whole page has been removed.
The benefit of this build and the emacs-w64 above is that they come with jpg, png, tiff DLLs as well as lxml DLL, which is needed for the new eww web browser.
I prefer to run Windows 10 + VcXsrv + Emacs 25 client in WSL. Emacs is my shell.
To access the .emacs file for your profile the easiest way is to open up emacs. Then do C-x C-, type in ~USERNAME/.emacs (or you can use init.el or one of the other flavours). Type your stuff into the file and C-x C-s (I think) to save it.
The actual file is located (in Windows XP) in c:\Documents and Settings\USERNAME.emacs.d(whatever you named the file), or the equivalent spelling/location on your system.
You can download GNU Emacs NT from here direct. It works fine in windows, make sure you create a shortcut to the runemacs.exe file rather than the emacs.exe file so it doesn't show a command prompt before opening!
XEmacs is less stable than GNU Emacs, and a lot of extensions are specifically written for GNU. I would recommend GNU > X.
You can place the .emacs file in the root of the drive it's installed on. Not sure whether you can add it elsewhere too...
Im using emacs32, I only have one problem with it really:
https://stackoverflow.com/questions/3625738/comint-previous-matching-input-in-emacsw32-is-not-interactive
If You Mean Emacs as Latex Editor for Windows 7.
Emacs4LS (Emacs 4 Latex Support under Windows 7) for newcomer for Emacs.
http://chunqishi.github.io/emacs4ls/
Easy Steps to Install.
Plugins Built-In.

Resources