wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Unable to get environment variables under wezterm, resulting in command unavailable

Open wangmings opened this issue 1 year ago • 0 comments

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20240624-065522-552bb1d6

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

In wezterm.lua environment can not get environment variables, resulting in a command, can not be used directly

To Reproduce

local wezterm = require 'wezterm'



function shell(cmd)
    local output = "null"
    local f = io.popen(cmd)
    if f ~= nil then
        output = f:read("*all")
        f:close()
    end
    return output
end


-- Unable to set or get environment variables
wezterm.log_info('shell: ' .. shell("echo $PATH"))
wezterm.log_info('os: ' ..os.getenv("PATH"))

-- Some shell commands cannot be used, such as:
wezterm.log_info('node -v: ' .. shell("node -v"))



return {
    
    font_size = 17.0,
    font = wezterm.font_with_fallback {
        {family = 'JetBrains Mono'},
        'Noto Color Emoji'
    },

    keys = {{ 
        key = 'g', 
        mods = 'CTRL', 
        action = wezterm.action.ShowDebugOverlay 
    }}
}

截屏2024-06-27 下午6 04 05

Configuration

You can execute shell directly in wezterm.lua

Expected Behavior

No response

Logs

No response

Anything else?

No response

wangmings avatar Jun 27 '24 10:06 wangmings