Sublime Forum

ST build system - how can I include path to compiler?

#1

hello,

On my system, I add temporarily the path to the compiler, then run the makefile:

source /opt/gcc/bin/
make

Is there a way I can add the compiler path to my custom build system?

"build_systems":
    [
        {
            "cmd":
            [
                "make"
            ],
            "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
            "name": "build",
            "selector": "source.makefile",
            "working_dir": "${file_path}"
        }
    ]

Can I do this with the build system directly?

0 Likes

#2

If you use shell_cmd instead of cmd, the internal exec command will execute the command you give by passing it directly to the shell instead of trying to invoke it directly. That means you can set shell_cmd to what you would normally enter in a terminal.

For example:

"shell_cmd": "source /opt/gcc/bin && make",

Note that where cmd takes an array of strings, shell_cmd takes a single string instead. As such you need to make sure to quote any arguments in the command that might contain spaces to ensure that they’re treated properly by the shell.

1 Like

#3

hello OdatNurd,

thank you for your reply. The command works in the shell. In ST, it looks like $PATH=""

because Once I set

"shell_cmd": "export PATH=/path/to/bin:$PATH && make",

I receive

/bin/bash: make: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: export PATH=/opt/gcc-arm-none-eabi-7-2017-q4-major/bin: && make]
[dir: /home/user/sublime_proj]
[path: /home/user/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/

without export PATH, make can be found

0 Likes

#4

there’s no need to set the PATH from the shell_cmd - set it in the env of your build system instead
http://www.sublimetext.com/docs/3/build_systems.html#exec_options

2 Likes

#5

with this make is found, but gcc isn’t:

.*.sublime-project

{
    "settings":
    {
        "env":
        {
            "Windows": 
            {
            },
            "Darwin": 
            {
            },
            "Linux": 
            {
                "PATH": "/opt/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH"
            }
        }
    },
    "build_systems":
    [
        {
            "cmd":
            [
                "make"
            ],
            "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
            "name": "Make",    
            "selector": "source.makefile",
            "working_dir": "${file_path}" 
        },
0 Likes

#6

why not try:

{
    "build_systems":
    [
        {
            "cmd":
            [
                "make"
            ],
            "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
            "name": "Make",    
            "selector": "source.makefile",
            "working_dir": "${file_path}",
            "linux": {
                "env": {
                   "PATH": "/opt/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH",
                },
            },
        },
    ],
}
0 Likes