Hemken / Statamarkdown

Functions to write Stata documentation with knitr
Other
59 stars 11 forks source link

Fix for macOS executable and 2 additional Unix executables #6

Closed remlapmot closed 2 years ago

remlapmot commented 5 years ago

Firstly, thanks indeed for this fantastic package and also for you SASmarkdown package. It is brilliant to be able to use Stata in Rmd files.

Two small fixes for your consideration:

  1. I think your macOS executable code needed this small fix. Essentially I don't think that your old code worked, hence I just deleted that part. Your new code is correct.

    (Apologies if you know all this) On macOS the .app file for an app is really a folder with the executables and other stuff inside. On macOS in for Stata in its .app/Contents/MacOS folder it actually has 2 executables, one for the GUI, which you're hitting and another for the executable for the Terminal (i.e. there's stata and Stata; or stata-se and StataSE, or stata-mp and StataMP depending upon which version you have). I think it's better to hit the Stata executable as you're doing as that one draws the plots in memory so you can graph export them in the Stata code chunk and then show them in a subsequent code chunk in your Rmd file.

  2. As far as I remember the executables for the different versions of Stata on Unix have 3 different names (stata, stata-se, stata-mp). You were just looking for stata, so I added searching over all 3.

Possible outstanding error

I think both the Mac and Unix versions may fail to run the Stata code chunks if the .Rmd file is saved in a filepath which has a space in its name. This is because Terminal commands of the form

stata -q -e do "/filepath with spaces/mydofile"

seem to fail (or at least they do on my Stata 15) even if I put quotes around the filepath. I suspect this may be a bug in the way Stata parses the command so I might ask Tech Support about this.

.Rproj file

Also personally I prefer to include my .Rproj files in my repos (i.e. remove this from your .gitignore but I agree .Rproj.user should be ignored). Note that you can add .Rproj and .Rproj.user to a .Rbuildignore file so those files don't get included in the built package.

Best wishes Tom Palmer

Hemken commented 5 years ago

Thanks. Saw this email as I was heading out the door for a vacation – I’ll look into these when I return.

From: Tom Palmer [mailto:notifications@github.com] Sent: Saturday, August 31, 2019 4:33 PM To: Hemken/Statamarkdown Cc: Subscribed Subject: [Hemken/Statamarkdown] Fix for macOS executable and 2 additional Unix executables (#6)

Firstly, thanks indeed for this fantastic package and also for you SASmarkdown package. It is brilliant to be able to use Stata in Rmd files.

Two small fixes for your consideration:

  1. I think your macOS executable code needed this small fix. Essentially I don't think that your old code worked, hence I just deleted that part. Your new code is correct.

(Apologies if you know all this) On macOS the .app file for an app is really a folder with the executables and other stuff inside. On macOS in for Stata in its .app/Contents/MacOS folder it actually has 2 executables, one for the GUI, which you're hitting and another for the executable for the Terminal (i.e. there's stata and Stata; or stata-se and StataSE, or stata-mp and StataMP depending upon which version you have). I think it's better to hit the Stata executable as you're doing as that one draws the plots in memory so you can graph export them in the Stata code chunk and then show them in a subsequent code chunk in your Rmd file.

  1. As far as I remember the executables for the different versions of Stata on Unix have 3 different names (stata, stata-se, stata-mp). You were just looking for stata, so I added searching over all 3.

Possible outstanding error

I think both the Mac and Unix versions may fail to run the Stata code chunks if the .Rmd file is saved in a filepath which has a space in its name. This is because Terminal commands of the form

stata -q -e do "/filepath with spaces/mydofile"

seem to fail (or at least they do on my Stata 15) even if I put quotes around the filepath. I suspect this may be a bug in the way Stata parses the command so I might ask Tech Support about this.

.Rproj file

Also personally I prefer to include my .Rproj files in my repos (i.e. remove this from your .gitignore but I agree .Rproj.user should be ignored). Note that you can add .Rproj and .Rproj.user to a .Rbuildignore file so those files don't get included in the built package.

Best wishes Tom Palmer


You can view, comment on, or merge this pull request online at:

https://github.com/Hemken/Statamarkdown/pull/6

Commit Summary

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/6?email_source=notifications&email_token=ACYBMEYUYCM774QIYNYGWO3QHLPR3A5CNFSM4ISU3JZ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HITOGIA, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBME7DDPMB7CVMNM2FLFDQHLPR3ANCNFSM4ISU3JZQ.

Hemken commented 5 years ago

Probably want to flip the search order, to use the most powerful Stata? On our linstat I find: stata-mp, stata-se, stata-ic, and a link, “stata” pointing to stata-mp.

From: Tom Palmer [mailto:notifications@github.com] Sent: Saturday, August 31, 2019 4:33 PM To: Hemken/Statamarkdown Cc: Subscribed Subject: [Hemken/Statamarkdown] Fix for macOS executable and 2 additional Unix executables (#6)

Firstly, thanks indeed for this fantastic package and also for you SASmarkdown package. It is brilliant to be able to use Stata in Rmd files.

Two small fixes for your consideration:

  1. I think your macOS executable code needed this small fix. Essentially I don't think that your old code worked, hence I just deleted that part. Your new code is correct.

(Apologies if you know all this) On macOS the .app file for an app is really a folder with the executables and other stuff inside. On macOS in for Stata in its .app/Contents/MacOS folder it actually has 2 executables, one for the GUI, which you're hitting and another for the executable for the Terminal (i.e. there's stata and Stata; or stata-se and StataSE, or stata-mp and StataMP depending upon which version you have). I think it's better to hit the Stata executable as you're doing as that one draws the plots in memory so you can graph export them in the Stata code chunk and then show them in a subsequent code chunk in your Rmd file.

  1. As far as I remember the executables for the different versions of Stata on Unix have 3 different names (stata, stata-se, stata-mp). You were just looking for stata, so I added searching over all 3.

Possible outstanding error

I think both the Mac and Unix versions may fail to run the Stata code chunks if the .Rmd file is saved in a filepath which has a space in its name. This is because Terminal commands of the form

stata -q -e do "/filepath with spaces/mydofile"

seem to fail (or at least they do on my Stata 15) even if I put quotes around the filepath. I suspect this may be a bug in the way Stata parses the command so I might ask Tech Support about this.

.Rproj file

Also personally I prefer to include my .Rproj files in my repos (i.e. remove this from your .gitignore but I agree .Rproj.user should be ignored). Note that you can add .Rproj and .Rproj.user to a .Rbuildignore file so those files don't get included in the built package.

Best wishes Tom Palmer


You can view, comment on, or merge this pull request online at:

https://github.com/Hemken/Statamarkdown/pull/6

Commit Summary

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/6?email_source=notifications&email_token=ACYBMEYUYCM774QIYNYGWO3QHLPR3A5CNFSM4ISU3JZ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HITOGIA, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBME7DDPMB7CVMNM2FLFDQHLPR3ANCNFSM4ISU3JZQ.

remlapmot commented 5 years ago

That's interesting.

On my Mac (I only have Stata SE version 15.1 on a Mac to test with) in Stata "Install Terminal Utility" puts a symbolic link, stata-se, in /usr/local/bin/ (which points at the binary within the app folder /Applications/Stata/StataSE.app/Contents/MacOS/stata-se).

Maybe the stata link always exists on Unix installations (but not on Mac)? Anyway, I'm happy to make the change about the order (if the stata link always exists clearly the other names won't matter). Or maybe the stata link is new for version 16.

remlapmot commented 5 years ago

I have

I have tested these on macOS but not on Linux.

cheers Tom

Hemken commented 5 years ago

Thanks for all this! I should be back on line and able to review in 2 weeks.

From: Tom Palmer [mailto:notifications@github.com] Sent: Monday, September 09, 2019 11:48 AM To: Hemken/Statamarkdown Cc: Doug Hemken; Comment Subject: Re: [Hemken/Statamarkdown] Fix for macOS executable and 2 additional Unix executables (#6)

I have

· stata-se -q -e do \"/Users/username/my docs/test.do\" produces my.log instead of test.log, i.e. it's taking the name of the log-file from upto the first space.

I have tested these on macOS but not on Linux.

cheers Tom

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/6?email_source=notifications&email_token=ACYBME4ZOO7DJB42EC5EWLTQIZ45HA5CNFSM4ISU3JZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6IJATA#issuecomment-529567820, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBME6APJSAZF5A3UOSUHLQIZ45HANCNFSM4ISU3JZQ.