Sublime Text Build System that just "make" - makefile

I'm trying to build my project by simple executing make in the top directory. However, when I do, I get the following error:
[Errno 2] No such file or directory
[cmd: [u'make']]
[dir: /Users/jonathanong/Workspace/template]
[path: /usr/local/bin]
[Finished]
This is after setting the build configuration to Make.
I'm on Sublime Text 2.0.1, OS X 10.8.2. My Makefile consists of executing globally installed node.js binaries. What do I have to do?

This is because make is not in your PATH. If you can build in the terminal, use which make to figure out the path to make, and then add that to the path for build. You can edit the makefile build system to add your path.
Your new makefile rule should look like:
{
"cmd": ["make"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${project_path:${folder:${file_path}}}",
"selector": "source.makefile",
"path": "/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin",
"variants":
[
{
"name": "Clean",
"cmd": ["make", "clean"]
},
{
"name": "Test",
"cmd": ["make", "test"]
}
]
}
This is basically the default make target, but I added to the PATH, and (of course) a test target. You may have to extend the PATH to find gcc, ifort, or whatever you are using to compile. Use : to separate directories on Linux and Mac, and ; on Windows. You can also change other environment variables, I had to set DYLD_LIBRARY_PATH and CPATH so that my libraries and include directories would be available.
It should be saved as Make (OSX).sublime-build in the User directory of your Sublime preferences. The (OSX) will ensure that this file is only used on Mac, so when you copy your preferences to a non-mac computer, you won't gunk up the path.

A much preferable solution is IMO to adjust the PATH in a plugin, so you have to set it just once for all build systems and all plugins calling external commands.
You can just do
import os
os.environ['PATH'] += os.pathsep + '/my/extra/path'
Real world example lives at https://github.com/schlamar/ST3User/blob/master/preferences.py

Related

Unable to automatically install go extensions in vscode

I am getting started with Go and would like to use Visual Studio Code for editing. I successfully installed go on my Ubuntu Computer.
My GOPATH (go env) is set to the same value as go.gopath in settings.json. If I run Go: Current GOPATH it outputs the correct path.
However, I am not able to install the go extensions. If I click on Install all I get output similar to this:
Installing 1 tool at home/jan/go/bin
dlv
Installing github.com/go-delve/delve/cmd/dlv FAILED
1 tools failed to install.
dlv:
Error: Command failed: /snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv
I seem to be able to just install packages manually with /snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv. The command runs without errors, but VSCode seems to be unable to find dlv.
My settings.json:
{
"terminal.integrated.rendererType": "dom",
"go.useLanguageServer": true,
"go.formatTool": "gofmt",
"go.lintOnSave": "file",
"go.vetOnSave": "package",
"go.buildOnSave": "package",
"go.lintTool": "golint",
"go.gopath": "home/jan/go"
}
I have git installed on my computer. It works without a problem.
Your GOPATH is not set correctly in settings.json.
"go.gopath": "home/jan/go"
This path is relative, and so it would be appended to whatever your working directory is, with the obvious result of not being able to find the path as it won't exist.
You can either set it correctly, or delete it and the GOPATH environment variable will be used. (I run it this way.)
"go.gopath": "/home/jan/go"

Issue with tasks not picking up correct ruby version

This issues comes a goes depending on the Ruby project I'm working on. VSCode Tasks often do not run from the proper rbenv shimmed Ruby version. Sometimes, if I manually run a command from the integrated terminal first, then run the Code task it picks up the correct Ruby.
Example VSCode Task,
{
"version": "2.0.0",
"tasks": [
{
"label": "Run All Tests",
"type": "shell",
"command": "bin/rails test",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}
When launching Code from the project directory (or any other way for that matter) if I run this task it runs from the context of the System ruby. However, if I open the integrated terminal and type bin/rails test (which works) then run the task again it will run in the proper rbenv shimmed ruby context.
Launching a debugger session however does work in the proper Ruby context, so I really don't understand what's being missed.
This answer will get tasks working, however it doesn't fix the underlying problem with VS Code. This probably needs to be an issue posted on their GitHub repo.
If you're on a Mac, this command will put a ruby symlink in your path that links to the rbenv version. Rbenv (and most applications) only change the path inside a shell environment (the .bash_profile only changes it for bash). This command will add it to the path regardless of what shell you run.
ln -s "/Users/$(whoami)/.rbenv/shims/ruby" /usr/local/bin/ruby
My guess is that VS Code is not actually using a shell environment and is instead calling the executable directly.
Until Visual Studio Code solves what seems to be a bug or missing configuration setting or, at least, missing documentation, I have resorted to setting the PATH variable on the task's command attribute.
For example, if the ruby I'm interested in using is at /full/path/to/bin/ruby, I prepend /full/path/to/bin to the PATH environment variable.
For example:
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "sidekiq",
"type": "shell",
"command": "export PATH=/full/path/to/bin:$PATH && bundle exec sidekiq -C config/sidekiq.yml",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
}
}]
}

haxelib to install with haxe in a custom directory

I'm trying to set up haxe development environment. I'd prefer not to install haxe in /usr, so I edited haxe Makefile so that the install directory is a local one:
INSTALL_DIR=/home/liori/Programy/haxe.install
However, now I cannot use haxelib:
% PATH=/home/liori/Programy/haxe.install/bin:$PATH haxelib setup /home/liori/Programy/haxe.install/haxelib
Standard library not found
How to execute haxelib in these circumstances?
Since the error mentioned "Standard library not found", probably the "std" folder is misplaced somehow.
The haxe standard lib folder, "std", should be placed right next to the "haxe" executable. If you want to have an alternative setup, you should set up an env variable, HAXE_STD_PATH, which points to the "std" folder. Try set it up and run haxelib again.
If that still doesn't work, try to open the haxelib executable in a text editor, it should be a script that runs haxe. See if any of the arguments is wrong.
Yet another option is to make haxelib, which will produce a compiled haxelib executable instead of the script based one.

SASS on Sublime Text 3 - [Decode error - output not utf-8]

I've been trying to use sass in sublime text 3 today and for that I installed Ruby, Ruby SASS gem and the Sublime packages Sass and Sass Build. All seems to be working well but when I try to build the css file (using the Sass Build package) I get this weird error:
[Decode error - output not utf-8]
[Finished in 0.1s with exit code 1]
[cmd: ['sass', '--update', 'F:\\Program Files (x86)\\wamp\\www\\singlepage\\wp-content\\themes\\manaca\\style.scss:F:\\Program Files (x86)\\wamp\\www\\singlepage\\wp-content\\themes\\manaca/style.css', '--stop-on-error', '--no-cache', '--style', 'compressed']]
[dir: F:\Program Files (x86)\wamp\www\singlepage\wp-content\themes\manaca]
[path: C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;F:\Program Files (x86)\MacType;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Autodesk\Backburner\]
And when I try to build the compressed CSS (from the same package) it simply returns
[Decode error - output not utf-8]
[Finished in 0.1s]
What's been bugging me is the crazy file paths returned in the last line (shouldn't even be searching in C: )
The other thing I've been researching about is the output not utf-8 thing. Even if I specify the charset on my sass (or scss) file, the problem lingers.
Anyway, I appreciate any type of help I can get.
"shell": true - this is the key.
If I try build-system like this (on WinXP):
{
"cmd": ["ant", "-f", "project-build.xml"],
"working_dir": "${project_path}"
}
I get:
[Decode error - output not utf-8]
because cmd should be "ant.bat" instead.
Sublime is looking for file exacly called ant and encoding of "file does not exist" message is not utf-8.
When I use shell like this:
{
"cmd": ["ant", "-f", "project-build.xml"],
"working_dir": "${project_path}",
"shell": true
}
everything works fine (even without "windows": { "cmd": ....} ) because shell searches for ant.exe and then ant.bat.
I've worked around the problem.
The path thing was a missing step of my Ruby installation on Windows. I needed to register Ruby's path in Environment Variables.
But still the package Sass Build wasn't working so I opened cmd and told Sass to watch the file, inside my website folder:
cd "program files (x86)\..\mysite"
sass --watch style.scss:style.css --style compact --no-cache
Now every time I save the style.scss file the css file is updated properly.
Hope that clarifies the process to anyone else!
Just a reference for people who had similar problem and the accepted answer didn't help:
I had a similar error, in my case I had to install python and add it to the PATH environment variable.
add ruby to envirement variable PATH.
I've got this error when I open Sublime Text from a console window. Open Sublime from a normal shortcut.
Just in case someone else comes across this on a different matter, I was building a project in openCL (using C API not C++) and encountered this error.
Turns out I hadn't allocated enough memory for the string to hold the program build log.

How to install SWIG?

Noob question ahead...
I'm trying to install SWIG on Windows. According to the INSTALL document, I have to
cd to the directory containing the package's source code and type ./configure to configure the package for your system.
I tried the command in both the root directory and in the /CCache directory (these are the only ones that have the configure and configure.in files), however, the shell reports back that
C:\swigwin-2.0.4>./configure
'.' is not recognized as an internal or external command,
operable program or batch file.
What am I missing?
no installation is needed. you just have to set the environment variable to point to the "swig" 's executable which is under the root directory of swig
On the SWIG site, you can download for example the swigwin-2.0.7 zip directory for windows's swig. unzip it in a directory of your choice for example on "C:\Program Files" directory if you want. After this, you have the swig executable in the "C:\Program Files\swigwin-2.0.7" directory: "C\Program Files\swigwin-2.0.7\swig"
you have to set now the environment variable "path" to point to this swig exec: add for this the "C:\Program Files\swigwin-2.0.7" path to the "path"variable according to my example; that is all you need to use swig on windows. You can now play with swig so, open a prompt "cmd" and just type "swig --help" on this prompt you can see a list of the differents options you can use with swig.
If you d'ont have visual c++, you can use for example codeblock, that is my case so the link below could be a help for you : http://wiki.codeblocks.org/index.phptitle=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system
The page http://www.swig.org/download.html has a specific download for Windows with a pre-built version of swig.exe. You can download it and avoid the hassle of compiling swig by yourself.
If you really need to, you can consult the file Doc/Manual/Windows.html that contain Windows-specific instructions to build SWIG.
Finally, to answer your specific question, the syntax
./configure
is a UNIX-style command that means 'execute the program named configure in the current directory' (the dot)
On Windows, you would type
.\configure
or even simpler, as all files are executable on Windows, only
configure
... BUT this will not work as the said 'configure' script is a bash script that will not run in a Windows shell.
Download Miniconda.
Then follow this guide and do: conda install -c anaconda swig

Resources