Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu, could not launch process: fork/exec ./debug: operation not permitted #515

ctaggart opened this issue Apr 26, 2016 · 14 comments


Copy link

@ctaggart ctaggart commented Apr 26, 2016

I'm on Ubuntu 14.04 and I am not sure what I'm doing wrong to get this error when I run dlv debug:

could not launch process: fork/exec ./debug: operation not permitted

I'm simply following the instructions at:

vscode@9d24dfa15aab:~$ cd $GOPATH/src/
vscode@9d24dfa15aab:~/go/src/$ go get -v -u (download) (download)
vscode@9d24dfa15aab:~/go/src/$ ls -al $GOPATH/bin/dlv
-rwxr-xr-x 1 vscode vscode 15499304 Apr 26 19:32 /home/vscode/go/bin/dlv
vscode@9d24dfa15aab:~/go/src/$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted
vscode@9d24dfa15aab:~/go/src/$ go version
go version go1.6.2 linux/amd64
vscode@9d24dfa15aab:~/go/src/$ dlv version
Delve Debugger
Version: 0.11.0-alpha
vscode@9d24dfa15aab:~/go/src/$ uname -a
Linux 9d24dfa15aab 4.4.6 #1 SMP Mon Apr 18 19:18:15 UTC 2016 x86_64 GNU/Linux
Copy link

@derekparker derekparker commented Apr 26, 2016

The updated install instructions for Linux now live here. Can you verify that after following those directions you still experience this issue? Try using the make install command from within the repo.

I'm running Ubuntu 16.04 and Go 1.6.2 and cannot reproduce with the gorename cmd.

Copy link

@ctaggart ctaggart commented Apr 26, 2016

Same result with

vscode@9d24dfa15aab:~/go/src/$ rm -rf $GOPATH/src/
vscode@9d24dfa15aab:~/go/src/$ go get
vscode@9d24dfa15aab:~/go/src/$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted


vscode@9d24dfa15aab:~/go/src/$ rm ~/go/bin/dlv 
vscode@9d24dfa15aab:~/go/src/$ dlv debug
-su: /home/vscode/go/bin/dlv: No such file or directory
vscode@9d24dfa15aab:~/go/src/$ go get
vscode@9d24dfa15aab:~/go/src/$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted

Copy link

@derekparker derekparker commented Apr 26, 2016

I assume from your example output that you are within the ~/go/src/ directory, which should contain main.go representing the main package, correct?

Can you run file $(which dlv) and paste the output, please?

Copy link

@ctaggart ctaggart commented Apr 26, 2016

vscode@9d24dfa15aab:~/go/src/$ ls
vscode@9d24dfa15aab:~/go/src/$ file $(which dlv)
-su: file: command not found`

Copy link

@derekparker derekparker commented Apr 26, 2016

@ctaggart and if you run go build -gcflags="-N -l" within that dir, are you able to run the resulting binary?

Copy link

@ctaggart ctaggart commented Apr 26, 2016

vscode@18a88cf9c29e:~/go/src/$ go build -ldflags="-N -l"
flag provided but not defined: -N
usage: link [options] main.o
  -B note
        add an ELF NT_GNU_BUILD_ID note when using ELF
  -C    check Go calls to C code
  -D address
        set data segment address (default -1)
  -E entry
        set entry symbol name
  -H type
        set header type
  -I linker
        use linker as ELF dynamic linker
  -L directory
        add specified directory to library path
  -R quantum
        set address rounding quantum (default -1)
  -T address
        set text segment address (default -1)
  -V    print version and exit
  -X definition
        add string value definition of the form
  -a    disassemble output
  -buildid id
        record id as Go toolchain build id
  -buildmode mode
        set build mode
  -c    dump call graph
  -cpuprofile file
        write cpu profile to file
  -d    disable dynamic executable
  -extar string
        archive program for buildmode=c-archive
  -extld linker
        use linker when linking in external mode
  -extldflags flags
        pass flags to external linker
  -f    ignore version mismatch
  -g    disable go package data checks
  -h    halt on error
  -installsuffix suffix
        set package directory suffix
  -k symbol
        set field tracking symbol
  -libgcc string
        compiler support lib for internal linking; use "none" to disable
  -linkmode mode
        set link mode (internal, external, auto)
        link against installed Go shared libraries
  -memprofile file
        write memory profile to file
  -memprofilerate rate
        set runtime.MemProfileRate to rate
        enable MSan interface
  -n    dump symbol table
  -o file
        write output to file
  -r path
        set the ELF dynamic linker search path to dir1:dir2:...
        enable race detector
  -s    disable symbol table
        generate shared object (implies -linkmode external)
  -tmpdir directory
        use directory for temporary files
  -u    reject unsafe packages
  -v    print link trace
  -w    disable DWARF generation

Copy link

@derekparker derekparker commented Apr 26, 2016

@ctaggart updated the above comment, I meant -gcflags not -ldflags, please try again with -gcflags, sorry.

Copy link

@ctaggart ctaggart commented Apr 26, 2016


vscode@18a88cf9c29e:~/go/src/$ go build -gcflags="-N -l"
vscode@18a88cf9c29e:~/go/src/$ ls          
gorename  main.go
vscode@18a88cf9c29e:~/go/src/$ gorename 
gorename: precise type-safe renaming of identifiers in Go source code.


 gorename (-from <spec> | -offset <file>:#<byte-offset>) -to <name> [-force]

You must specify the object (named entity) to rename using the -offset
or -from flag.  Exactly one must be specified.


-offset    specifies the filename and byte offset of an identifier to rename.
           This form is intended for use by text editors.

-from      specifies the object to rename using a query notation;
           This form is intended for interactive use at the command line.
           A legal -from query has one of the following forms:

  "encoding/json".Decoder.Decode        method of package-level named type
  (*"encoding/json".Decoder).Decode     ditto, alternative syntax
  "encoding/json".Decoder.buf           field of package-level named struct type
  "encoding/json".HTMLEscape            package member (const, func, var, type)
  "encoding/json".Decoder.Decode::x     local object x within a method
  "encoding/json".HTMLEscape::x         local object x within a function
  "encoding/json"::x                    object x anywhere within a package
  json.go::x                            object x within file json.go

           Double-quotes must be escaped when writing a shell command.
           Quotes may be omitted for single-segment import paths such as "fmt".

           For methods, the parens and '*' on the receiver type are both

           It is an error if one of the ::x queries matches multiple

-to        the new name.

-force     causes the renaming to proceed even if conflicts were reported.
           The resulting program may be ill-formed, or experience a change
           in behaviour.

           WARNING: this flag may even cause the renaming tool to crash.
           (In due course this bug will be fixed by moving certain
           analyses into the type-checker.)

-d         display diffs instead of rewriting files

-v         enables verbose logging.

gorename automatically computes the set of packages that might be
affected.  For a local renaming, this is just the package specified by
-from or -offset, but for a potentially exported name, gorename scans
the workspace ($GOROOT and $GOPATH).

gorename rejects renamings of concrete methods that would change the
assignability relation between types and interfaces.  If the interface
change was intentional, initiate the renaming at the interface method.

gorename rejects any renaming that would create a conflict at the point
of declaration, or a reference conflict (ambiguity or shadowing), or
anything else that could cause the resulting program not to compile.


$ gorename -offset file.go:#123 -to foo

  Rename the object whose identifier is at byte offset 123 within file file.go.

$ gorename -from '"bytes".Buffer.Len' -to Size

  Rename the "Len" method of the *bytes.Buffer type to "Size".

---- TODO ----

- handle dot imports correctly
- document limitations (reflection, 'implements' algorithm).
- sketch a proof of exhaustiveness.

- support running on packages specified as *.go files on the command line
- support running on programs containing errors (loader.Config.AllowErrors)
- allow users to specify a scope other than "global" (to avoid being
  stuck by neglected packages in $GOPATH that don't build).
- support renaming the package clause (no object)
- support renaming an import path (no ident or object)
  (requires filesystem + SCM updates).
- detect and reject edits to autogenerated files (cgo, protobufs)
  and optionally $GOROOT packages.
- report all conflicts, or at least all qualitatively distinct ones.
  Sometimes we stop to avoid redundancy, but
  it may give a disproportionate sense of safety in -force mode.
- support renaming all instances of a pattern, e.g.
  all receiver vars of a given type,
  all local variables of a given type,
  all PkgNames for a given package.
- emit JSON output for other editors and tools.

Copy link

@ctaggart ctaggart commented Apr 26, 2016

I tagged what I currently have as 0.0.2. You can reproduce and troubleshoot directly on the docker image. Here are the steps:

docker run --rm -it ctaggart/golang-vscode:0.0.2 su - vscode
cd $GOPATH/src/
dlv debug
Camerons-iMac:golang-vscode cameron$ docker run --rm -it ctaggart/golang-vscode:0.0.2 su - vscode
Unable to find image 'ctaggart/golang-vscode:0.0.2' locally
0.0.2: Pulling from ctaggart/golang-vscode
efd26ecc9548: Already exists 
a3ed95caeb02: Pull complete 
d1784d73276e: Already exists 
72e581645fc3: Already exists 
01ce90e06b06: Already exists 
dd49ac13b118: Already exists 
3f4ffd08203e: Already exists 
5852efbc7938: Already exists 
6f409912964d: Pull complete 
62f278e9fb96: Pull complete 
Digest: sha256:84c879adf8302aaacf9a2ac72be42157ae0bc2e6b7d93741fa9019cc03c5879a
Status: Downloaded newer image for ctaggart/golang-vscode:0.0.2
vscode@793f6aa806dd:~$ cd $GOPATH/src/
vscode@793f6aa806dd:~/go/src/$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted

The relevant build files are:

Copy link

@derekparker derekparker commented Apr 26, 2016

Alright, so you're running within a Docker container. Docker has security settings preventing ptrace(2) operations by default with in the container. Pass --security-opt=seccomp:unconfined to docker run when starting.

Copy link

@ctaggart ctaggart commented Apr 27, 2016

Thank you!

Camerons-iMac:golang-vscode cameron$ docker run --rm -it --security-opt seccomp=unconfined ctaggart/golang-vscode:0.0.2 su - vscode
vscode@64057935aa4e:~$ cd $GOPATH/src/
vscode@64057935aa4e:~/go/src/$ dlv debug
Type 'help' for list of commands.

Copy link

@jkryanchou jkryanchou commented Nov 9, 2017

@derekparker awesome, It works.

Copy link

@e-gautier e-gautier commented Dec 29, 2017

@derekparker Thank you.

Copy link

@virtuald virtuald commented Aug 13, 2018

I ran into this and it took awhile for my google search to find this. Is there a way dlv can know that it's running into this particular error and output a helpful hint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants