Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 247 - Enh: Can't reliably find standard file locations in Nyquist plug-ins
Enh: Can't reliably find standard file locations in Nyquist plug-ins
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Nyquist
unspecified
PC Windows (all)
: P4 Repeatable
Assigned To: Steve Daulton
http://audacity.238276.n2.nabble.com/...
: nyquist
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-20 13:07 UTC by Steve Daulton
Modified: 2019-05-14 13:09 UTC (History)
3 users (show)

See Also:
Steps To Reproduce:
In the Nyquist Prompt enter the following code and press the Debug button. (get-env 'home)
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Daulton 2010-10-20 13:07:00 UTC
According to this discussion http://audacity.238276.n2.nabble.com/Setting-Nyquist-working-directory-td4134136.html#a4144136
(GETENV) should return the HOME directory.

Tested on all platforms - it returns NIL.
Comment 1 Steve Daulton 2010-10-21 11:53:09 UTC
(In reply to comment #0)
It appears that there was an error in a comment and the correct function name is (GET-ENV)

This is in the latest source, but not in Audacity 1.3.12.

(get-env 'home) and (get-env "HOME") both work in Audacity 1.3.13 (SVN trunk) on Linux - not yet tested on Mac or Windows.

To test, enter the following in the Nyquist prompt:
(get-env 'home)

This should print the path of the HOME directory.

(If "HOME" is double quoted it must be upper case)
Comment 2 Gale Andrews 2010-10-21 12:54:31 UTC
(In reply to comment #1)
> (get-env 'home) and (get-env "HOME") both work in Audacity 1.3.13 (SVN trunk)
> on Linux - not yet tested on Mac or Windows.
> To test, enter the following in the Nyquist prompt:
> (get-env 'home)
On SVN HEAD on Win 7 x64, (get-env 'home) and (get-env "HOME") both produce "Nyquist did not return audio" without any debug output.
Comment 3 Steve Daulton 2010-10-21 13:40:12 UTC
(In reply to comment #2)
Bill W. reports that it works correctly on his G5 PPC Mac running 1.3.13-alpha-Oct 19 2010 so I've changed this to "Windows (all)"
Comment 4 Steve Daulton 2010-10-21 13:51:58 UTC
(In reply to comment #2)
Could you try (get-env "HOMEPATH")
Comment 5 Gale Andrews 2010-10-21 14:17:22 UTC
(In reply to comment #4)
> Could you try (get-env "HOMEPATH")
Produces "Nyquist did not return audio" on both Win 7 and Ubuntu 10.10. No debug output on Ubuntu but on Windows produces:

error: unbound function - GET-ENV
if continued: try evaluating symbol again
1>
Comment 6 Steve Daulton 2010-10-22 09:29:44 UTC
(In reply to comment #5)
(GET-ENV) is only in recent (not sure how recent) builds from SVN.

There's a whole load of alternatives that are coming up on this forum thread
http://forum.audacityteam.org/viewtopic.php?f=39&t=42368

It may be more efficient to continue the discussion there, then update this bugzill entry with the outcome.
Comment 7 Gale Andrews 2010-10-22 12:38:20 UTC
(In reply to comment #6)
> (GET-ENV) is only in recent (not sure how recent) builds from SVN
On both Ubuntu 10.10 and Win 7 x64, I am only checking on SVN HEAD
Comment 8 Steve Daulton 2010-10-28 07:46:47 UTC
(In reply to comment #7)
This issue appears to be largely resolved in the current svn code.

What we currently do not have is documentation other than in this forum thread:
http://forum.audacityteam.org/viewtopic.php?f=39&t=42368

There is still a problem with Unicode characters, but that is a broader issue and I'm unsure if it is a "bug" or just a limitation of Nyquist/Lisp. Either way it is a different issue to (get-env).

If there are no objections, I propose that this bug can be closed, but (get-env) needs to be properly documented.
Where?
Comment 9 Gale Andrews 2010-10-28 14:47:44 UTC
(In reply to comment #8)
Resolved "WORKSFORME" - no changes needed to current SVN HEAD. As regards OS'es supported by Audacity,  

(or (get-env "HOME") (get-env "UserProfile"))

should always return user's home directory. 

> (get-env) needs to be properly documented.Where? 

I've stored this in the "Nyquist Conventions" thread in the Forum:
http://forum.audacityteam.org/viewtopic.php?f=39&t=42106&p=109405#p109405 

Ultimately the material in that thread should move to 
http://wiki.audacityteam.org/wiki/Nyquist_Audio_Programming

when decisions are made about how to re-structure that page and how to structure pages that are linked to it.
Comment 10 Steve Daulton 2018-10-29 08:43:00 UTC
I'm reopening this bug (as an enhancement) for a few reasons:

1) While the "home" directory can usually be found in Nyquist via environmental variables (example below), it is not guaranteed to be reliable, and we have seen cases where there are unexpected results due to non-standard environment variables being set.

Example:
(cond ((get-env 'UserProfile))
      ((get-env 'home)))


2) With the recent advances in scripting and macro commands, there are many more cases where it would be useful for a Nyquist script to be able to reliably find some standard locations, such as "home", the system "temp" folder, the recommended user plug-in directory, and the path to the Nyquist .lsp files (so that we can ship optional functions / macros without changing the standard Nyquist symbol table).


3) Nyquist provides some standard locations, such as the function "(get-temp-path)", but they are not cross-platform friendly (trailing file-separators vary across platforms).


4) The property list *system-dir* has proved effective, and can easily be extended to include additional useful paths (namely those suggested in item 2.)

(directories set in Audacity preferences are already available via "aud-do" so no need to duplicate these.)

Assigned to myself (as it fits with my "aud-do function wrapper" project).
Comment 11 Steve Daulton 2018-10-29 08:45:56 UTC
Updated bug description for "Enhancement".
Comment 12 Steve Daulton 2018-11-12 07:12:35 UTC
(In reply to Steve Daulton from comment #11)
The "HOME" directory is now available with:
(print (get '*system-dir* 'home))


The Audacity "temp" folder is now available with:
(print (get '*system-dir* 'temp))

The 'system' temp folder is available with:
(print (get-temp-path))
but on Windows this relies on environment variables and may fail in some cases, so there is now (hopefully more reliable) the system temp from Wx:
(print (get '*system-dir* 'sys-temp))

The default user plug-in directory:
(print (get '*system-dir* 'user-plug-in))

The path to the Nyquist .lsp files:
(print *NYQ-PATH*)

Directories set in Audacity preferences are available via "aud-do"

Remaining to close this bug: Update docs.
Comment 13 Peter Sampson 2019-05-13 08:46:34 UTC
(In reply to Steve Daulton from comment #12)
>Remaining to close this bug: Update docs.

@Steve:  has this update to the docs been done - i.e. can we close this bug as RESOLVED ?
Comment 14 Steve Daulton 2019-05-14 13:09:12 UTC
(In reply to Peter Sampson from comment #13)
Yes, it's all documented here:
https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#globals
and here:
https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#property_lists

Closing this as resolved-fixed.