MCPcopy Index your code
hub / github.com/jetify-com/devbox / createDevboxSymlink

Function createDevboxSymlink

internal/devbox/pure_shell.go:16–33  ·  view source on GitHub ↗

Creates a symlink for devbox in .devbox/bin so that devbox can be available inside a pure shell

(d *Devbox)

Source from the content-addressed store, hash-verified

14// Creates a symlink for devbox in .devbox/bin
15// so that devbox can be available inside a pure shell
16func createDevboxSymlink(d *Devbox) error {
17 // Get absolute path for where devbox is called
18 devboxPath, err := os.Executable()
19 if err != nil {
20 return errors.Wrap(err, "failed to create devbox symlink. Devbox command won't be available inside the shell")
21 }
22 // ensure .devbox/bin directory exists
23 binPath := dotdevboxBinPath(d)
24 if err := os.MkdirAll(binPath, 0o755); err != nil {
25 return errors.WithStack(err)
26 }
27 // Create a symlink between devbox and .devbox/bin
28 err = os.Symlink(devboxPath, filepath.Join(binPath, "devbox"))
29 if err != nil && !errors.Is(err, fs.ErrExist) {
30 return errors.Wrap(err, "failed to create devbox symlink. Devbox command won't be available inside the shell")
31 }
32 return nil
33}
34
35func dotdevboxBinPath(d *Devbox) string {
36 return filepath.Join(d.ProjectDir(), ".devbox/bin")

Callers 1

ShellMethod · 0.85

Calls 2

dotdevboxBinPathFunction · 0.85
IsMethod · 0.80

Tested by

no test coverage detected