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

Updates for Goal scripting language, in Code, Numbers, Author. #355

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ go install cogentcore.org/cogent/code/cmd/cogentcode@latest

* See Releases on this github page for pre-built OS-specific app packages that install the compiled binaries.

## MacOS environment variables

When `Code` is run from an installed mac app bundle, it does not inherit the normal shell environment. To set environment variables in a way that extends to GUI apps, you must use:
```sh
launchctl setenv VAR VALUE
```
The `goal` shell automatically does this for you when setting any environment variables.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user sets an environment variable in the interactive shell, there is absolutely no way that they expect it to make changes to the underlying system environment. At the very least this should only apply to things in the .goal file, given that I could do set A test or something in the interactive shell while experimenting, and I absolutely would not want that stored in the system forever!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, designing a system that is wholly incompatible with most people's shells is not tenable. Cogent Code must support someone who uses bash and wants to be able to run commands.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just running all commands through separate Goal processes in Cogent Code, which would bypass the environment variable issue entirely since Goal would get the right environment variables on startup? We will be replacing a lot of the current command infrastructure with a Goal terminal interface soon anyway.


This does not extend to the `PATH` variable, which requires this command:
```sh
sudo launchctl config user path $PATH
```
This only takes effect after a reboot. Also, once done, then the default shell path will have that path, already, so commands to set the path in the shell will end up with duplicates.

# Future Plans

We plan to incorporate [gopls](https://github.com/golang/tools/tree/master/gopls) to provide more comprehensive Go language IDE-level support, similar to what is found in VS Code. At present, the completion can be a bit spotty for some kinds of expressions, and the lookup "go to definition" functionality is also not perfect. However, the basic code editing dynamics are pretty solid, so adding gopls would bring it much closer to feature-parity with VS Code.
Expand Down
11 changes: 0 additions & 11 deletions code/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ type SettingsData struct { //types:add
// file picker settings
Files FileSettings

// environment variables to set for this app -- if run from the command line, standard shell environment variables are inherited, but on some OS's (Mac), they are not set when run as a gui app
EnvVars map[string]string

// if set, the current customized set of language options (see Edit Lang Opts) is saved / loaded along with other settings -- if not set, then you always are using the default compiled-in standard set (which will be updated)
SaveLangOpts bool

Expand Down Expand Up @@ -117,7 +114,6 @@ func (se *SettingsData) Open() error {
func (se *SettingsData) Apply() { //types:add
MergeAvailableCmds()
AvailableLanguages.Validate()
se.ApplyEnvVars()
}

// SetGoMod applies the given gomod setting, setting the GO111MODULE env var
Expand All @@ -129,13 +125,6 @@ func SetGoMod(gomod bool) {
}
}

// ApplyEnvVars applies environment variables set in EnvVars
func (se *SettingsData) ApplyEnvVars() {
for k, v := range se.EnvVars {
os.Setenv(k, v)
}
}

func (se *SettingsData) MakeToolbar(p *tree.Plan) {
tree.Add(p, func(w *core.FuncButton) {
w.SetFunc(se.EditLangOpts).SetIcon(icons.Subtitles)
Expand Down
Loading