Opening a filename from the command line doesn't work
@pmurias - Hmm, which OS are you on?
Debian Linux
On 11 December 2016 at 19:40, extr0py notifications@github.com wrote:
@pmurias https://github.com/pmurias - Hmm, which OS are you on?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/extr0py/oni/issues/84#issuecomment-266298974, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGXpoYrkyWzyTYOkB3iqfVViPe7lSwkks5rHEOcgaJpZM4LJ_bJ
.
Works in the HEAD revision, only seems to be broken in the version on npm.
On 11 December 2016 at 20:12, Paweł Murias pawelmurias@gmail.com wrote:
Debian Linux
On 11 December 2016 at 19:40, extr0py notifications@github.com wrote:
@pmurias https://github.com/pmurias - Hmm, which OS are you on?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/extr0py/oni/issues/84#issuecomment-266298974, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGXpoYrkyWzyTYOkB3iqfVViPe7lSwkks5rHEOcgaJpZM4LJ_bJ
.
@pmurias - interesting, thanks for the details. That's strange that it works when built locally but not via npm install -g oni-vim. I just tried on my windows box (unfortunately, I don't have an easily accessible Linux box at the moment), and was unable to repro.
The command-line parsing makes the assumption that there will be two items prior to the filename - this is the relevant code in main.js:
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
createWindow(process.argv.slice(2))
})
Would be interesting to know what process.argv is in both those cases, (like using console.dir(process.argv))
There's also a potential that something in the ipc layer is working differently. The browser process gets the argument at the bottom of browser\src\index.tsx:
ipcRenderer.on("init", (_evt, message) => {
start(__message.args__)
})
Would be useful to know what message.args is in this case
process.argv is the same in both instances. I opened the main.js in each project.
npm install -g oni-vim
[ '/usr/lib/node_modules/oni-vim/node_modules/electron/dist/electron',
'/usr/lib/node_modules/oni-vim/main.js',
'main.js' ]
built locally:
[ '/home/keforbes/Documents/oni/node_modules/electron/dist/electron',
'/home/keforbes/Documents/oni/main.js',
'main.js' ]
I also tried printing message.args in both scenarios but neither one had any output. I'm guessing this method isn't running in either case.
When launching from npm install -g oni-vim, the oni window is created but has no content. There is a red blinking cursor in the top-left and an otherwise black screen. If I hit <esc> it draws an empty file (white blinking cursor on first line, blue ~ on all other lines, bottom white line says "main.js [RO]"
$ file /usr/lib/node_modules/oni-vim/.travis.yml /home/keforbes/Documents/oni/.travis.yml
/usr/lib/node_modules/oni-vim/.travis.yml: ASCII text, with CRLF line terminators
/home/kforbes/Documents/oni/.travis.yml: ASCII text
The files built in npm have ^Ms in them (dos format).
Only certain files have ^Ms though:
Files /usr/lib/node_modules/oni-vim/.editorconfig and /home/keforbes/Documents/oni/.editorconfig differ
Files /usr/lib/node_modules/oni-vim/.gitattributes and /home/keforbes/Documents/oni/.gitattributes differ
Files /usr/lib/node_modules/oni-vim/index.html and /home/keforbes/Documents/oni/index.html differ
Files /usr/lib/node_modules/oni-vim/LICENSE and /home/keforbes/Documents/oni/LICENSE differ
Files /usr/lib/node_modules/oni-vim/main.js and /home/keforbes/Documents/oni/main.js differ
Files /usr/lib/node_modules/oni-vim/.npmignore and /home/keforbes/Documents/oni/.npmignore differ
Files /usr/lib/node_modules/oni-vim/package.json and /home/keforbes/Documents/oni/package.json differ
Files /usr/lib/node_modules/oni-vim/README.md and /home/keforbes/Documents/oni/README.md differ
Files /usr/lib/node_modules/oni-vim/ROADMAP.md and /home/keforbes/Documents/oni/ROADMAP.md differ
Files /usr/lib/node_modules/oni-vim/TODO.md and /home/keforbes/Documents/oni/TODO.md differ
Files /usr/lib/node_modules/oni-vim/.travis.yml and /home/keforbes/Documents/oni/.travis.yml differ
EDIT: Nevermind, I think all files have dos format. The output of the diff command I ran only had these files but after manually checking a couple directories, everything has dos format.
This looks to be another occurrence of #7 but it affects files outside the bin/ directory. @extr0py, you'll probably have to convert those files on your system since my git auto-converted the line endings (as you mentioned in #7).
Confirmed. I ran dos2unix on everything installed by npm install -g oni-vim and oni can open files with oni <filename> now.
$ find . | grep -v node_modules/ | xargs file | grep CRLF | cut -d':' -f1 | sudo xargs dos2unix
Great investigation @keforbes - thanks for all the details! Makes sense, it seems like the CRLF is clearly the culprit. I'll plan on doing future submissions from a Linux machine, since that seems like the safest route. Additionally, it'd be nice to configure auto-publish for TravisCI on tagged commits, which would help here too.
I set up Ubuntu on a spare machine and pushed 0.1.4 from there. Installing via npm install -g oni-vim works, and I can also do oni <filename>. Closing this out, but in the future the publish could be automated from TravisCI, which would be nice - used #95 to track that. Thanks again for the investigation, @keforbes !
Most helpful comment
Confirmed. I ran
dos2unixon everything installed bynpm install -g oni-vimand oni can open files withoni <filename>now.