Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-12 Thread Greg Hendershott
People hit this using GUI Emacs on macOS -- and use the
`exec-path-from-shell` Emacs Lisp package:

  https://github.com/purcell/exec-path-from-shell




Ever find that a command works in your shell, but not in Emacs?

This happens a lot on OS X, where an Emacs instance started from the
GUI inherits a default set of environment variables.

This library solves this problem by copying important environment
variables from the user's shell: it works by asking your shell to
print out the variables of interest, then copying them into the Emacs
environment.




The source is <270 lines of Emacs Lisp -- of which >200 is comments
and boilerplate.

Maybe someone could make an equivalent DrRacket plugin and provide it
as a Racket package?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Robby Findler
On Sat, Nov 11, 2017 at 12:14 PM, Alexis King  wrote:
>> On Nov 11, 2017, at 08:17, Robby Findler 
>> wrote:
>>
>> One example that lives on (in a zombie-like state) is the "search in
>> files" functionality
>
> Sort of off-topic, but I use the Search in Files option all the time,
> so don’t think nobody’s finding it useful!

Yay! :)


Robby

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Alexis King
> On Nov 11, 2017, at 08:17, Robby Findler 
> wrote:
> 
> One example that lives on (in a zombie-like state) is the "search in
> files" functionality

Sort of off-topic, but I use the Search in Files option all the time,
so don’t think nobody’s finding it useful!

(Also, I virtually always launch DrRacket using the drracket launcher
executable that `raco setup` produces, but I don’t know that I have an
especially good reason for doing that. I imagine I started doing it at
one point for a reason, but I have since forgotten about what that
reason was.)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick
On Nov 11, 2017, at 10:07 AM, Matthew Butterick  wrote:
> 
>> On Nov 11, 2017, at 8:17 AM, Robby Findler > > wrote:
>> 
>> There is definitely a tension here, but my experience
>> suggests that it would  not be a good use of my time to do something
>> like that. At least, not without a clear pain point in my own mind.
>> Since you see to have one of those, however, maybe you should give
>> something a try?
> 
> Sure. I wasn't intending to frame this as "here's something new for Robby to 
> do" ;)

(PS But I don't use environment variables enough to impose my dumb-person's 
solution on the world, so I am content with the status quo)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick

> On Nov 11, 2017, at 8:17 AM, Robby Findler  
> wrote:
> 
> There is definitely a tension here, but my experience
> suggests that it would  not be a good use of my time to do something
> like that. At least, not without a clear pain point in my own mind.
> Since you see to have one of those, however, maybe you should give
> something a try?

Sure. I wasn't intending to frame this as "here's something new for Robby to 
do" ;)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Robby Findler
FWIW, I have spent (far too much) time trying to replicate
functionality in DrRacket that is best just used in the underlying OS
or its tools somehow. One example that lives on (in a zombie-like
state) is the "search in files" functionality and there are others
that just died. There is definitely a tension here, but my experience
suggests that it would  not be a good use of my time to do something
like that. At least, not without a clear pain point in my own mind.
Since you see to have one of those, however, maybe you should give
something a try? As Matthew pointed out, there is already command-line
support (that I think doesn't get used much because it isn't very
convenient to use) that you could use a starting point for wiring
things in.

Robby


On Thu, Nov 9, 2017 at 11:29 AM, Matthew Butterick  wrote:
> I see your point. But this technique forfeits any broader compatibility with
> desktop-oriented tools (e.g., file launchers and whatnot)
>
> I did try making an Automator application containing a shell script that
> simply launches DrRacket, and also tried `bash -c ···` (to try to force it
> to launch from inside a login session). But these didn't change the result.
>
> Anyhow, add it to the giant pile of things in the world that are more
> complex than I thought.
>
>
> On Nov 8, 2017, at 8:07 PM, John Clements  wrote:
>
> On Nov 8, 2017, at 12:42, Robby Findler  wrote:
>
> How about "env X=Y racket -l- drracket file-to-open-in-drracket.rkt” ?
>
>
> +1
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-09 Thread Matthew Butterick
I see your point. But this technique forfeits any broader compatibility with 
desktop-oriented tools (e.g., file launchers and whatnot)

I did try making an Automator application containing a shell script that simply 
launches DrRacket, and also tried `bash -c ···` (to try to force it to launch 
from inside a login session). But these didn't change the result.

Anyhow, add it to the giant pile of things in the world that are more complex 
than I thought.


> On Nov 8, 2017, at 8:07 PM, John Clements  wrote:
> 
>> On Nov 8, 2017, at 12:42, Robby Findler > > wrote:
>> 
>> How about "env X=Y racket -l- drracket file-to-open-in-drracket.rkt” ?
> 
> +1

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-09 Thread Konrad Hinsen

On 08/11/2017 17:48, 'John Clements' via Racket Users wrote:


IIRC, Mac has an apologetic moue towards unix-y things here: I believe there’s 
a special place in your home directory … or maybe it’s in 
~/Library/Preferences, which would …

okay, let me search.

Okay, here you go:

https://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x#588442


That link points to the two good solutions (the one the link points to, 
and the one just after it) for setting global environment variables with 
recent versions of macOS. The second one (lauchctl setenv ...) is often 
the better one, in particular because it can be used on a per-user basis.


It's worth pointing out that macOS has changed its handling of 
environment variables a few times in the past, so you can easily find 
suggestions and recipes that no longer work, or (almost worse) no longer 
work reliably. The best known one of these is modifying 
$HOME/.MacOS/environment.plist, which was the preferred approach in some 
distant past.


If you want the same environment variables in a shell running in a 
terminal and in GUI-based applications, you have to take care in 
configuring both environments in the same way. The obvious approach 
might seem to be not to set environments in the shells at all, letting 
them inherit the global environment, but given that the terminal app 
runs shells as login shells, this doesn't work.


Konrad.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread 'John Clements' via Racket Users

> On Nov 8, 2017, at 12:42, Robby Findler  wrote:
> 
> How about "env X=Y racket -l- drracket file-to-open-in-drracket.rkt” ?

+1

John



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Jack Firth

>
> I wonder whether a submodule is a better approach here. DrRacket 
> implicitly runs a `test` submodule, while `racket` doesn't, and you 
> could add more submodules to the list in DrRacket. But that approach 
> doesn't work if the conditional adjustment goes in a library, instead 
> of the main module. 
>

The library could provide a language that added the needed submodules 
automatically, much like how `configure-runtime` submodules are currently 
added.

What about an `interaction` submodule that worked sort of like `main`, but 
was run when a program is both run as the main program *and *run in an 
environment where the user expects to interact with the live running 
program in some way? The default `#%module-begin` of `racket/base` could 
add an `interaction` submodule that implements the normal racket REPL, 
while a domain specific language for configuring a server (think of 
something like #lang htaccess) could provide a "REPL" that lets you "do 
stuff" to the server, like restart it, reload config, etc.

My thinking is that the important distinction is not about whether a 
program is running in a dev environment or a prod environment - it's about 
whether the programmer wishes to *interact* with the program after running 
it. How to interact with the running program should be defined by the 
program itself, not tools on top of the program. Tools should only allow a 
programmer to declare their intent to interact.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Robby Findler
How about "env X=Y racket -l- drracket file-to-open-in-drracket.rkt" ?

Robby


On Wed, Nov 8, 2017 at 2:18 PM, Matthew Butterick  wrote:
>>> In this case I was trying to configure a web servlet to run in differently
>>> when launched from DrRacket (in terms of its port and servlet-path) to 
>>> better
>>> approximate Apache / htaccess conditions that exist on the live web server.
>>
>> I wonder whether a submodule is a better approach here. DrRacket
>> implicitly runs a `test` submodule, while `racket` doesn't, and you
>> could add more submodules to the list in DrRacket. But that approach
>> doesn't work if the conditional adjustment goes in a library, instead
>> of the main module.
>
> Right. `serve/servlet` is invoked with a bunch of keyword arguments, and I 
> only need to change a few. So AFAICT adding bindings with a submodule 
> wouldn't work.
>
> Furthermore the `test` submodule is also invoked by `raco test`, so I avoid 
> using it for things that assume the presence of DrRacket.
>
>
>> Maybe DrRacket should let you configure environment variables for a
>> program in the same way that it lets you provide command-line
>> arguments, and maybe it does make sense to have a default environment
>> variable that means "running in development mode".
>
> Right. It seems analogous to some of those other settings.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Butterick
>> In this case I was trying to configure a web servlet to run in differently 
>> when launched from DrRacket (in terms of its port and servlet-path) to 
>> better 
>> approximate Apache / htaccess conditions that exist on the live web server. 
> 
> I wonder whether a submodule is a better approach here. DrRacket
> implicitly runs a `test` submodule, while `racket` doesn't, and you
> could add more submodules to the list in DrRacket. But that approach
> doesn't work if the conditional adjustment goes in a library, instead
> of the main module.

Right. `serve/servlet` is invoked with a bunch of keyword arguments, and I only 
need to change a few. So AFAICT adding bindings with a submodule wouldn't work.

Furthermore the `test` submodule is also invoked by `raco test`, so I avoid 
using it for things that assume the presence of DrRacket.


> Maybe DrRacket should let you configure environment variables for a
> program in the same way that it lets you provide command-line
> arguments, and maybe it does make sense to have a default environment
> variable that means "running in development mode".

Right. It seems analogous to some of those other settings.





-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Leif Andersen
> Maybe DrRacket should let you configure environment variables for a
program in the same way that it lets you provide command-line
arguments

Yes. Please.

Although just like command line arguments I could see this being a
thing I want to change on a per-program basis, so I guess that's a
point against it. :/



~Leif Andersen


On Wed, Nov 8, 2017 at 2:51 PM, Matthew Flatt  wrote:
> At Wed, 8 Nov 2017 10:55:13 -0800, Matthew Butterick wrote:
>>
>> > On Nov 8, 2017, at 9:17 AM, Matthew Flatt  wrote:
>> >
>> > DrRacket tries not to interfere with programs in a detectable way.
>>
>> Hmm ... so if DrRacket adopts a different set of environment variables from
>> command-line `racket` — which I assume is the correct and just policy — isn't
>> that naturally going to lead to detectable differences, for a program that
>> depends on those variables?
>
> As others have said, both `racket` and `DrRacket` just accept the
> environment variables that the environment gives them, and Finder and
> bash set up different environments.
>
>> > Is there something more general that you want to test for DrRacket ---
>> > some effect on the execution environment that might be due to DrRacket
>> > or some other tool/configuration? If so, it could make sense to set up
>> > some way of communicating that to a program.
>>
>> In this case I was trying to configure a web servlet to run in differently
>> when launched from DrRacket (in terms of its port and servlet-path) to better
>> approximate Apache / htaccess conditions that exist on the live web server.
>
> I wonder whether a submodule is a better approach here. DrRacket
> implicitly runs a `test` submodule, while `racket` doesn't, and you
> could add more submodules to the list in DrRacket. But that approach
> doesn't work if the conditional adjustment goes in a library, instead
> of the main module.
>
> Maybe DrRacket should let you configure environment variables for a
> program in the same way that it lets you provide command-line
> arguments, and maybe it does make sense to have a default environment
> variable that means "running in development mode".
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Flatt
At Wed, 8 Nov 2017 10:55:13 -0800, Matthew Butterick wrote:
> 
> > On Nov 8, 2017, at 9:17 AM, Matthew Flatt  wrote:
> > 
> > DrRacket tries not to interfere with programs in a detectable way.
> 
> Hmm ... so if DrRacket adopts a different set of environment variables from 
> command-line `racket` — which I assume is the correct and just policy — isn't 
> that naturally going to lead to detectable differences, for a program that 
> depends on those variables?

As others have said, both `racket` and `DrRacket` just accept the
environment variables that the environment gives them, and Finder and
bash set up different environments.

> > Is there something more general that you want to test for DrRacket ---
> > some effect on the execution environment that might be due to DrRacket
> > or some other tool/configuration? If so, it could make sense to set up
> > some way of communicating that to a program.
> 
> In this case I was trying to configure a web servlet to run in differently 
> when launched from DrRacket (in terms of its port and servlet-path) to better 
> approximate Apache / htaccess conditions that exist on the live web server. 

I wonder whether a submodule is a better approach here. DrRacket
implicitly runs a `test` submodule, while `racket` doesn't, and you
could add more submodules to the list in DrRacket. But that approach
doesn't work if the conditional adjustment goes in a library, instead
of the main module.

Maybe DrRacket should let you configure environment variables for a
program in the same way that it lets you provide command-line
arguments, and maybe it does make sense to have a default environment
variable that means "running in development mode".

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Leif Andersen
> Hmm ... so if DrRacket adopts a different set of environment variables from 
> command-line `racket` —...

It actually doesn't. This is just because you are opening it with
macos's application framework...thingy

On the other hand, if you run drracket directly from the command line
(by running the `/bin/drracket`), you will notice that
you get the same environment variables that you do with command line
racket.

The moral of the story is that you can detect different environment
variables that your OS gives you when you start the process, but that
does not really correspond to if you are running in DrRacket or
command line racket.

~Leif Andersen


On Wed, Nov 8, 2017 at 1:55 PM, Matthew Butterick  wrote:
>
> On Nov 8, 2017, at 9:17 AM, Matthew Flatt  wrote:
>
> DrRacket tries not to interfere with programs in a detectable way.
>
>
> Hmm ... so if DrRacket adopts a different set of environment variables from
> command-line `racket` — which I assume is the correct and just policy —
> isn't that naturally going to lead to detectable differences, for a program
> that depends on those variables?
>
> For instance, it seems odd that DrRacket agrees with `racket` on #"USER" and
> #"LOGNAME" being #"MB", but #"PATH" is totally different.
>
> In DrRacket it's #"/usr/bin:/bin:/usr/sbin:/sbin", but I don't know where
> that comes from.
>
> Moreover, suppose I had a racket shell script that depended on my user
> "PATH". I don't see how I could test that program in DrRacket without
> dropping a `(putenv PATH "my_user_path")` at the top.
>
>
> On Nov 8, 2017, at 8:48 AM, John Clements  wrote:
>
> IIRC, Mac has an apologetic moue towards unix-y things here: I believe
> there’s a special place in your home directory … or maybe it’s in
> ~/Library/Preferences, which would …
>
> https://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x#588442
>
>
> We are in a maze of twisty little passages, all alike.
>
>
>
> Is there something more general that you want to test for DrRacket ---
> some effect on the execution environment that might be due to DrRacket
> or some other tool/configuration? If so, it could make sense to set up
> some way of communicating that to a program.
>
>
> In this case I was trying to configure a web servlet to run in differently
> when launched from DrRacket (in terms of its port and servlet-path) to
> better approximate Apache / htaccess conditions that exist on the live web
> server.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Flatt
At Wed, 8 Nov 2017 08:31:13 -0800, Matthew Butterick wrote:
> 2) Is there an environment variable that I can use to test if a
> program is running in DrRacket? For instance, the "XPC_SERVICE_NAME"
> variable has the value "org.racket-lang.DrRacket.39428". Though AFAIK
> that is a Mac OS specific value.

DrRacket tries not to interfere with programs in a detectable way.

Is there something more general that you want to test for DrRacket ---
some effect on the execution environment that might be due to DrRacket
or some other tool/configuration? If so, it could make sense to set up
some way of communicating that to a program.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.