Giter Site home page Giter Site logo

Comments (10)

pwntester avatar pwntester commented on August 13, 2024

Im using v0.6.0-dev+26-g9c7e04eb3 on MacOS Big Sur

I printed the options var on line 388 of lua.job and got:

{
  args = { "auth", "status" },
  command = "gh",
  env = { "NO_COLOR=1" },
  stdio = { <userdata 1>, <userdata 2>, <userdata 3> }
}

Also, printing self.pid after the call to spawn Im getting ENOENT: no such file or directory

When not using the env, I get:

{
  args = { "auth", "status" },
  command = "gh",
  stdio = { <userdata 1>, <userdata 2>, <userdata 3> }
}

and self.pid returns a correct pid

from plenary.nvim.

Conni2461 avatar Conni2461 commented on August 13, 2024

Can you run make test (i dont know if plenary busted even works on mac os) so you might only want to try this:

local results = {}
local job = Job:new {
command = 'env',
env = { 'A=100' },
on_stdout = function(_, data)
table.insert(results, data)
end,
}
job:sync()
assert.are.same(job:result(), { 'A=100' })
assert.are.same(job:result(), results)

And i am currently writing libuv c script to figure out where the problem is.

Another thing would be to write a luv script and check that. I will send you more snippets :)

from plenary.nvim.

pwntester avatar pwntester commented on August 13, 2024

Just found out that passing the absolute path to spawn's command make it work:

  local job =
    Job:new(
    {
      enable_recording = true,
      command = "/usr/local/bin/gh",
      args = opts.args,
      on_exit = vim.schedule_wrap(
        function(j_self, _, _)
          if mode == "async" and opts.cb then
            local output = table.concat(j_self:result(), "\n")
            local stderr = table.concat(j_self:stderr_result(), "\n")
            opts.cb(output, stderr)
          end
        end
      ),
      env = { NO_COLOR = 1 },
    }
  )
  if mode == "sync" then

Which is inconvenient since I have to figure out the path myself before calling gh.
Not sure what the reason is, maybe, passing an env table with only one var, overrides all PATH 🤔

from plenary.nvim.

pwntester avatar pwntester commented on August 13, 2024

Not sure what the reason is, maybe, passing an env table with only one var, overrides all PATH

Yep, that seems to be the case since gh is no longer authenticated when setting the NO_COLOR var.
I think the solution would be to merge vim.env with the passed env table. Does it make sense?

from plenary.nvim.

Conni2461 avatar Conni2461 commented on August 13, 2024

Maybe try { path = vim.env["PATH"], NO_COLOR = 1 }

from plenary.nvim.

Conni2461 avatar Conni2461 commented on August 13, 2024

We can't merge the tables we cant look in vim.env table, because its a metatable.

from plenary.nvim.

pwntester avatar pwntester commented on August 13, 2024

Maybe try { path = vim.env["PATH"], NO_COLOR = 1 }

That seems to be enough to get gh working. Thanks!

from plenary.nvim.

Conni2461 avatar Conni2461 commented on August 13, 2024

I would just pick the once you need? According to libuv docs if env is NULL it will take the parent environment: http://docs.libuv.org/en/v1.x/process.html#c.uv_process_options_t.env

from plenary.nvim.

pwntester avatar pwntester commented on August 13, 2024

Wondering why does it work for you on linux then 🤔

from plenary.nvim.

stevenhansel avatar stevenhansel commented on August 13, 2024

Can confirm that this happens to me too on MacOS M1 @pwntester
I used the absolute path solution that you mentioned and it worked fine for me now

from plenary.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.