NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.07k stars 14.13k forks source link

nodePackages.vercel: it's not using the system Go for Go cloud functions on vercel dev #165857

Open lucasew opened 2 years ago

lucasew commented 2 years ago

Describe the bug

I am doing a project and running it locally using vercel dev.

This project uses a Golang cloud function on the API folder

Instead of using the system Go or reference it as a dependency it's using the provided go from @vercel/go so it triggers that problem when you run a binary that expects a FHS system but it's NixOS

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a simple project with an HTML file or something like this
  2. Add at least one cloud function (using the api folder using go
  3. vercel dev

Expected behavior

vercel uses the system available Go, or the one declared as dependency

Screenshots

[nix-shell:~/WORKSPACE/irrigationProject]$ vercel dev                                                                             [28/919]
Vercel CLI 24.0.0                                   
> Running Dev Command “react-scripts start”         
ℹ 「wds」: Project is running at http://192.168.1.10/ 
ℹ 「wds」: webpack output is served from              
ℹ 「wds」: Content not from webpack is served from /home/lucasew/WORKSPACE/irrigationProject/public
ℹ 「wds」: 404s will fallback to /                    
Starting the development server...                  

> Ready! Available at http://localhost:3000         
Error! Command failed: go build -ldflags -s -w -o /nix/store/wqmssw3p3khlf4sp4g14m73kfmqpjdpk-vercel-24.0.0/lib/node_modules/vercel/node_m
odules/@vercel/go/dist/analyze /nix/store/wqmssw3p3khlf4sp4g14m73kfmqpjdpk-vercel-24.0.0/lib/node_modules/vercel/node_modules/@vercel/go/d
ist/analyze.go     

Additional context

Notify maintainers

@kidonng

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.16.14, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.7.0`
 - nixpkgs: `/nix/store/f71alr07xb2swc37fiqjr5h416qcs6wr-source`
lucasew commented 6 months ago

LOL image

SuperSandro2000 commented 4 months ago

Please also convert the package to using buildNpmPackage when fixing this issue.

lucasew commented 4 months ago

I think I found out the issue.

vercel dev looks for the go version in go.mod to know which go version to get. So the ideal here is to wrap vercel in a FHS environment so it works. Sometimes it's intentional using an older version.

SuperSandro2000 commented 4 months ago

They are doing it wrong. The go keyword denotes the language version to use, not the compiler. They should just use the go version from PATH.