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

Error Running on Windows 10 #10

Open
Damon980 opened this issue Nov 11, 2019 · 17 comments
Open

Error Running on Windows 10 #10

Damon980 opened this issue Nov 11, 2019 · 17 comments

Comments

@Damon980
Copy link

Hi,

I'm trying to run Stata code through VS Code using your extension, but I get an error when I attempt to run using ctrl + shift + a. It reads "Running the contributed command: 'stataRun.runAll' failed."

I followed the instructions for Windows step by step and I think they all finished properly, but I'm not sure how to check. I'm not very familiar with VS Code, I'm just trying to avoid using batch files to run my Stata files.

In the developer's console, this is the entire output after clearing and attempting to run.

[Extension Host] entering sendCode function
console.ts:137 [Extension Host] requiring winax
console.ts:137 [Extension Host] Error: Cannot find module 'C:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1/node_modules/winax'Require stack:- c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\sendCode.js- c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\stataRun.js- c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js- c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js- c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:627:15) at Function.Module._load (internal/modules/cjs/loader.js:531:27) at Function.t._load (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:796:719) at Function.n._load (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:765:302) at Function.i._load (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:761:870) at Module.require (internal/modules/cjs/loader.js:685:19) at n (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:524) at Object.defineWinax (c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\sendCode.js:49:14) at Object.sendWindows (c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\sendCode.js:63:25) at Object.send (c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\sendCode.js:37:21) at c:\Users\djoconnor4.vscode\extensions\yeaoh.statarun-2.0.1\stataRun.js:76:30 at v._executeContributedCommand (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:527:863) at v.$executeContributedCommand (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:528:217) at f._doInvokeHandler (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:646:285) at f._invokeHandler (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:645:999) at f._receiveRequest (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:644:664) at f._receiveOneMessage (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:643:477) at c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:641:754 at l.fire (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:207) at _.fire (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:187:274) at c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:798:104 at l.fire (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:207) at _.fire (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:187:274) at t.PersistentProtocol._receiveMessage (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:191:629) at c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:188:824 at l.fire (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:207) at f.acceptChunk (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:184:737) at c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:184:89 at Socket.t (c:\Users\djoconnor4\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:193:68) at Socket.emit (events.js:200:13) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11) at Socket.Readable.push (_stream_readable.js:210:10) at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166

@poidstotal
Copy link
Owner

Hi, Sorry that you run into issue. I couldn't text the windows version, @Najsztub did some contribution to get it to work, perhaps he can look into the issue for you. Please make sure you're running the latest version first.

Gratitudes
Gilbert M.

@Najsztub
Copy link
Contributor

Najsztub commented Nov 22, 2019

Dear @Damon980 ,

I didn't have to use Stata for a while, but now I've returned to it and found that after updating (the package or Code) I had to redo the install of the winax package. Unfortunately using this extension under Windows requires a bit of an effort to install.

So basically what I had to do:

I already had done npm install --global --production windows-build-tools@2.2.1

  1. I updated Node.js on my computer to the newest version.

  2. Version of the package has changed so I had to cd %USERPROFILE%\.vscode\extensions\yeaoh.statarun-2.0.3.

  3. After the update I had to reinstall winax using npm install winax --python=%USERPROFILE%\.windows-build-tools\python27\python.exe

  4. Then I run npm rebuild winax --runtime=electron --target=ELECTRON_VERSION --build-from-source with ELECTRON_VERSION as 12.4.0 (Node.js for my Code install).

Unfortunately that wasn't enough and I kept getting NODE_MODULE_VERSION error on run. I've found a solution of a similar issue here.

So! I run the following

npm i -D electron-rebuild
npm i
node_modules\.bin\electron-rebuild -v 6.1.2

The 6.1.2 is the VSCode Electron version from the About window.

Finally I once again run npm rebuild winax --runtime=electron --target=12.4.0 --build-from-source.

And I finally got the extension up and running again.

Hope this helps,
Mateusz

@domus11move
Copy link

Dear @Najsztub ,

Which version of stata are you using? Did you try with stata 16? Thanks for your tutorial

Cheers

@Najsztub
Copy link
Contributor

Hey,

I tried it only with Stata 15.

Best,
M

@davidxiaoyuxu
Copy link

Hi all,

I followed the instruction step by step, and set the Stata path to my "StataSE-64.exe". However, when I try to run selected command lines, nothing happens.

@IgorK7
Copy link

IgorK7 commented Sep 7, 2020

Hi, I also followed all the instructions and I am still getting "Running the contributed command: 'stataRun.runAll' failed." Simple Stata commands
set obs 10
gen a = 2

I am on Windows 10 and Stata 15.1 MP
I am not sure how to debug this error as no output is shown in CS Code.
Can someone help with making this extension running?

@peter-mccrory
Copy link

peter-mccrory commented Sep 9, 2020

Not sure if this will work for anyone else, but this is what I did:

  1. Installed version 12.8.3 of node.js (most recent version)
  2. Opened up Powershell as admin and ran: npm install --global --production windows-build-tools
  3. Opened up the command shell and typed: cd %USERPROFILE%\.vscode\extensions\yeaoh.statarun-2.0.3
  4. Then typed npm install winax@1.20.0
  5. Then rebuilt using npm rebuild winax --runtime=electron --target=7.3.2 --build-from-source, where 7.3.2 is the version of Electron that I saw in the About section of my VSCode.

I then turned on Stata Automation following the directions here: https://www.stata.com/automation/. I added the path to the executable in my user settings in VSCode and reloaded the VSCode window.

I then made a file called test.do with the line sysuse auto, clear and used the shortcut ctrl + shift + a to run all lines. My Stata opened up and ran the line.

Note: I don't have much of a clue what I'm doing. I am using Windows 10 for the first time since I recently built myself a pc (long-time user of Mac). Somehow, this worked.

@IgorK7
Copy link

IgorK7 commented Sep 9, 2020

I was able to follow instructions posted by @Najsztub Najsztub above without any errors. I ran everything in Power Shell (should do everything that cmd can do). In VSCode I get the same error "Running the contributed command: 'stataRun.runAll' failed."

I get some warning like :

  1. npm i -D electron-rebuild
    npm WARN deprecated request@2.88.2: request has been deprecated, see Request’s Past, Present and Future request/request#3142
    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
    npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

  2. npm i
    npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

@peter-mccrory
Copy link

@IgorK7 I was getting those errors when following the instructions posted by @Najsztub . Any luck with the instructions I just posted?

Note: I did a full reset before attempting anything new (uninstalling the extension, deleting the extension folder in .\vscode\extensions, uninstalling Node.js.

@IgorK7
Copy link

IgorK7 commented Sep 10, 2020

@peter-mccrory Thank you very much for getting back to me.
Yes. I tried to follow the way you did.
I did the following:

  1. removed all extensions and deleted the folder with extensions,
  2. uninstalled VSCode and Node/js
  3. then installed everything back again.

I cannot run the following command, it shows an error
npm rebuild winax --runtime=electron --target=7.3.2 --build-from-source

_C:\Users\%USERNAME%\.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v7.3.2/node-v7.3.2-headers.tar.gz
gyp ERR! stack at Request. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:188:14)
gyp ERR! stack at Request.emit (events.js:327:22)
gyp ERR! stack at Request.onRequestResponse (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:1066:10)
gyp ERR! stack at ClientRequest.emit (events.js:315:20)
gyp ERR! stack at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
gyp ERR! stack at TLSSocket.socketOnData (_http_client.js:469:22)
gyp ERR! stack at TLSSocket.emit (events.js:315:20)
gyp ERR! stack at addChunk (_stream_readable.js:295:12)
gyp ERR! stack at readableAddChunk (_stream_readable.js:271:9)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\%USERNAME%\.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! winax@1.20.0 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the winax@1.20.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\%USERNAME%\AppData\Roaming\npm-cache_logs\2020-09-10T01_50_24_825Z-debug.log_

It seems like I need to put the current version of Node.js that VS Code uses. It is 12.8.1
So, when I run:
npm rebuild winax --runtime=electron --target=12.8.1 --build-from-source
I get no errors. Can someone help me to troubleshoot this issue? Are there any logs that I could check for possible errors? Thanks

@IgorK7
Copy link

IgorK7 commented Sep 10, 2020

Also, to register Stata, I set the path to Stata folder in PowerShell (as Admin) and the run
StataMP-64 /Register
Do I need to do anything else here?

@peter-mccrory
Copy link

I had to set the path to the Stata executable in the settings.json in vscode. I did not add Stata to the Windows PATH environment variable. Honestly, I tried a bunch of different approaches based on what was in this repo and what was in the Atom stata-exec repo. What I posted above worked for me but I'm sorry it's not working for you!

@IgorK7
Copy link

IgorK7 commented Sep 10, 2020

Ok. I was able to make it work.
I did the following:

  1. Reinstall Node.js with the version 12.8.1
    This is the version that is supported by my VS Code.
  2. Deleted and reinstalled stataRun
  3. Followed @Najsztub instructions EXCEPT:
  4. npm rebuild winax --runtime=electron --target=7.3.2 --disturl=https://atom.io/download/atom-shell --build-from-source
    So it seems like I borrowed winax source files from Atom. I could not find anything similar for VSCode.

Also, registering StataMP-64.exe is not necessary

My general impression is that although it is very cool and nerdy and it finally works, it does not really worth it. Native node modules require exact matches of Node.js and Electron versions. I think it can cause a lot of hustle. If VSCode shifts to a different version, one may need to recompile winax again (It is my guess but I am not sure).
To sum up, I would not recommend using this extension on Windows -- My personal opinion.

@peter-mccrory
Copy link

To the point that @IgorK7 just made, my VSCode just updated to a new version of Electron and the previously working extension (yesterday) just broke 😢

@IgorK7
Copy link

IgorK7 commented Sep 12, 2020

@peter-mccrory same thing here. None of the previous solutions (including mine) works now and the problem seem to be deeper now. I get errors:
C:\Users%USERNAME%.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax\src\main.cpp(13,48): error C4430: missing type specifier - int assu
med. Note: C++ does not support default-int [C:\Users%USERNAME%.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax\build\node_activex.vcx
proj]
C:\Users%USERNAME%.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax\src\main.cpp(14,22): error C2065: 'context': undeclared identifier
C:\Users%USERNAME%.vscode\extensions\yeaoh.statarun-2.0.3\node_modules\winax\build\node_activex.vcxproj]

It looks like there is something wrong in the way how winax compiles for Electron version 9.2.1

It worked nicely for me only for a couple of days (((

@elektrotiko
Copy link

Are there any updates? This does not work anymore.

@2sls
Copy link

2sls commented Jan 27, 2021

Really appreciate the creator for this extension.

I am coming from Sublime where there is already a working package (https://github.com/andrewheiss/SublimeStataEnhanced) for Stata running in Windows and I know there is one for Atom as well (https://github.com/kylebarron/stata-exec).

Just curious if any logic there can be repurposed here to get this extension to run reliably in Windows.

[EDIT: I realize this package closely follows the Atom package already so my comment wasn't that helpful. But while browsing Kyle Barron's package, he mentioned a stata-jupyter kernel that would be useful for Windows user. Can that logic apply here?]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants