Bugzilla – Bug 247
Enh: Can't reliably find standard file locations in Nyquist plug-ins
Last modified: 2019-05-14 13:09:12 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.
(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)
(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.
(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)"
(In reply to comment #2) Could you try (get-env "HOMEPATH")
(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>
(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.
(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
(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?
(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.
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).
Updated bug description for "Enhancement".
(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.
(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 ?
(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.