Panic error when importing a github pachage

Hello, can anyone help me solve this problem, I got this error when importing a Github package:
panic: project_home_dir env variable was not provided, this is needed for training

Which one?

This is the whole error:

panic: PROJECT_HOME_DIR Env variable was not provided, this is needed for training

goroutine 1 [running]:
github.com/mutdroco/mpquic_for_video_stream_backend.(*scheduler).setup(0xc000180000)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/scheduler.go:82 +0x4d8
[github.com/mutdroco/mpquic_for_video_stream_backend.(*session).setup(0xc00000c1e0](http://github.com/mutdroco/mpquic_for_video_stream_backend.(*session).setup(0xc00000c1e0), 0x0, 0x76cf00, 0x8, 0xc000001980, 0x0, 0x0, 0x0, 0x7d16b8, 0xc00005e040, …)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/session.go:218 +0x496
[github.com/mutdroco/mpquic_for_video_stream_backend.glob..func2(0x7d16b8](http://github.com/mutdroco/mpquic_for_video_stream_backend.glob..func2(0x7d16b8), 0xc00005e040, 0xc00013c000, 0x1, 0x76cf00, 0x8, 0x200, 0x91f2ac35231d8394, 0xc000001980, 0xc000140090, …)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/session.go:177 +0x185
[github.com/mutdroco/mpquic_for_video_stream_backend.(*client).createNewSession(0xc00013c070](http://github.com/mutdroco/mpquic_for_video_stream_backend.(*client).createNewSession(0xc00013c070), 0x0, 0x0, 0x0, 0x7d16b8, 0xc00005e040, 0x10, 0x710f00)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/client.go:397 +0xcb
[github.com/mutdroco/mpquic_for_video_stream_backend.(*client).establishSecureConnection(0xc00013c070](http://github.com/mutdroco/mpquic_for_video_stream_backend.(*client).establishSecureConnection(0xc00013c070), 0x7d16b8, 0xc00005e040, 0x8, 0x76cf09)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/client.go:210 +0x6b
[github.com/mutdroco/mpquic_for_video_stream_backend.DialNonFWSecure(0x7d1ed8](http://github.com/mutdroco/mpquic_for_video_stream_backend.DialNonFWSecure(0x7d1ed8), 0xc000010040, 0x7cecb0, 0xc000076930, 0x76cf00, 0xd, 0xc000001980, 0xc00010bec8, 0xc00013c000, 0xc00010bd88, …)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/client.go:137 +0x40d
[github.com/mutdroco/mpquic_for_video_stream_backend.Dial(0x7d1ed8](http://github.com/mutdroco/mpquic_for_video_stream_backend.Dial(0x7d1ed8), 0xc000010040, 0x7cecb0, 0xc000076930, 0x76cf00, 0xd, 0xc000001980, 0xc00010bec8, 0xc00013c000, 0xc00010be10, …)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/client.go:153 +0x9a
[github.com/mutdroco/mpquic_for_video_stream_backend.DialAddr(0x76cf00](http://github.com/mutdroco/mpquic_for_video_stream_backend.DialAddr(0x76cf00), 0xd, 0xc000001980, 0xc00010bec8, 0x0, 0x0, 0xc000036680, 0x40fc18)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/client.go:60 +0x14e
main.main()

Based on the top of the stack trace in the error message you got, I opened http://github.com/mutdroco/mpquic_for_video_stream_backend and then opened scheduler.go and went to around line 82, where I saw this:

func (sch *scheduler) setup() {
	sch.projectHomeDir = os.Getenv(constants.PROJECT_HOME_DIR)
	if sch.projectHomeDir == "" {
		panic("`PROJECT_HOME_DIR` Env variable was not provided, this is needed for training")
	}

Though I don’t understand what this pavkage does, ot does seem to need this “PROJECT_HOME_DIR” to be defined.

2 Likes

Thank you so much for your reply, I’m new to Golang so it is a little bit hard to handle with this code, but I’m learning a lot from your recommendations.

I tried to define the PROJECT_HOME_DIR in the constants package as follow:

  • PROJECT_HOME_DIR = " #absolute-path-to-my-project"
  • PROJECT_HOME_DIR = “GOPATH”
    I also tried to define it as a command-line argument:
  • go run project.go " #absolute-path-to-my-project"
  • go run project.go “GOPATH”

But it still gave me the same error!

There is an interesting note in the readme file said: “Essential Environment Variables: OUTPUT_DIR="ABSOLUTE_PATH_TO_OUTPUT_DIR is needed for scheduler implementation in native application”… but I don’t know how to essential it and where?

Define PROJECT_HOME_DIR environment variable in your shell/OS before running your code, or via os.Setenv from your code before it calls the code that requires PROJECT_HOME_DIR.

1 Like

I use this command to set the env var: export PROJECT_HOME_DIR=“absolute/path” but I got other errors:

github.com/mutdroco/mpquic_for_video_stream_backend.(*scheduler).setup(0xc000180000)
/home/mininet/go/pkg/mod/github.com/mutdroco/mpquic_for_video_stream_backend@v0.0.0-20210705113800-59caa7259644/scheduler.go:92 +0x4bc
[github.com/mutdroco/mpquic_for_video_stream_backend.(*session).setup(0xc00000c1e0](http://github.com/mutdroco/mpquic_for_video_stream_backend.(*session).setup(0xc00000c1e0), 0x0, 0x76cf00, 0x8, 0xc000001980, 0x0, 0x0, 0x0, 0x7d16b8, 0xc000060040, …)

I guess that the project is still in development.

Failure to open a file. Not very user-friendly coding. You either need to be able to track down the reasons for these panics from the code referenced in the stack trace or find a different package.

linFileName := sch.projectHomeDir + "/sch_out/lin"
	file, err := os.OpenFile(linFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
	if err != nil {
		panic(err)
	}
1 Like

I agree with you I have to find another package to work with, thank you so much for your help

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.