Tag: programming

  • File Editing, Chromebooks, and Development

    Continuing on a tilt from my previous post on developing from a Chromebook, there are still lots of rough edges, even for developing toy projects, primarily stemming from file-system access. A simple rule has kept me out the weeds: for Node.js projects develop only from Android apps using Android app-private storage.

    The File System

    The Termux documentation partitions storage into three categories: private-app, shared-internal, and external. You won’t see the shared-internal storage from Termux until you run termux-setup-storage.

    It appears that under Chrome OS, all Android apps have the same file permissions, which will allow you to edit source files using vim to be read by Node.js, for example. There are, however, lots of operations from Android that fail with shared-internal storage. Creating symbolic links (ln) and updating permissions fail (chmod). Running npm from the shared-internal storage results in lots of errors of the form “Error: EPERM: operation not permitted…”

    The default Chrome OS document root used for file selection runs on top of the Storage Access Framework, but the default root only provides access to video, music, and SD-card, not to the private Android emulator storage. Here lies the obstacle between using Chrome apps to build executables for Termux or Crouton.

    Editors

    Given the rift between Android app-private and shared storage, I find it’s easiest to edit files using Android apps. There are several editors available within a few keystrokes of Termux, e.g. vim, though I wish I knew how to have multiple Termux windows open at once.

    A work around to multiple windows is to use another Android app as an editor. Turbo Editor can access Termux private data once you enable the storage-access-framework option under settings. It provides syntax highlighting for HTML and JavaScript files. Under my installation, it periodically pauses, sometimes forgetting to remove the dialog box announcing the pause.

    Other Directions

    I’ve been scurrying about today looking for alternative methods of editing source code and general file-system access from Chromebooks:

    • Use window.webkitRequestFileSystem() Chrome has supported HTML5 file-system operations for several years now. File access is partitioned by the requesting website and stored locally in Chrome private storage.
    • Chrome app file storage. Google has discontinued support for Chrome apps outside of Chrome OS. Will they do the same within Chrome OS? chrome.fileSystem is not available to Chrome extensions.
    • Chrome storage. Chrome provides a key-value service similar to window.localStorage, except that the data are synced with the user across machines.
    • Expose file-operations to a web client. noide is an Node.js application that provides a web interface to edit source files. It has gyp dependencies that are broken from Chrome OS. There are a couple of projects that provide web-client editor widgets, one could leverage to present a front-end for a file server build with Express.
    • Use Eclipse Che or Cloud 9, but that’s not really developing on a Chromebook….
    • Switch to developer mode and replace Termux with Crouton, which reportedly yields a more faithful Linux experience, including running Electron.
    • Drop any notion of keeping local files.
  • Developing and Serving React Apps from Chromebooks

    Yesterday I started to collect some notes on setting up React, Typescript, Babel, Webpack, Karma…. Holy cow! How many tools do you need just to get hello-react running? Fortunately, a web search short circuited most of that when the Interweb powers showed me Facebook’s create-react-app script “bundled” with recent versions of npm.

    pkg install git    # you have to save your work
    pkg install nodejs
    npx create-react-app lookout-unicorns
    cd lookout-unicorns
    npm start
    

    A couple of command-line entries later, node was scanning a directory, transpiling Typescript, running tslint and unit tests, and serving up the results. It was so easy, you must be able to do this on a Chromebook….

    There aren’t many steps here. First install Termux, nominally an Android terminal emulator, but green-circle gateway to Linux from Chrome OS. We’ll briefly use its package manager to bootstrap into the npm world.

    Now point your browser to http://localhost:3000. Chrome, surprisingly doesn’t recognize the URL, but Firefox for Android running on Chrome OS does.If you want to use Chrome to view your fruits…. Chrome OS assigns the Android emulator a private IP address which you can get from ifconfig in Termux or Crouton. This won’t be the same IP address assigned to your Chromebook by the network, but oddly Chrome OS will expose port 3000 to the world on your Chromebook’s IP address to the rest of the network, just not to its own Chrome browser….

  • Chromebooks for Developers?

    Earlier this year, my mother-in-law-J’s hand-me-down MacBook kicked the bucket. To reduce complexity and “support” phone time, my wife convinced me to buy her a Chromebook. I still worry about not being able to help out (and I’m a sucker for gadgets), so I blew the net savings from the Chromebook gift in comparison to the potential MacBook purchase on a second Chromebook.

    There are two stories here, one short and one developing…. The short story is that since for most people a Chromebook only runs a browser, there’s really no support beyond figuring out web services. We’ve yet to receive a cry for help from J. To increase n to 2, we gave mother-in-law-L a Chromebook for Christmas 5ish years ago…. and I wouldn’t know she used it ever, except that she says that she does and I occasionally see it on the kitchen island.

    The longer story is what I should do with the extra Chromebook….

    The Hardware

    I dragged my feet on buying Chromebooks until BestBuy had a sale. Google had a sales rep at BestBuy, and from his enthusiasm, I think I might have been his only customer ever. I don’t think he believed that I was going to buy a pair, even, as he took my photo and walked me to the cashier. In the end, I bought two Samsung Chromebook Pros.

    The display is beautiful, generating guilt never to use the touch screen; there’s a built in stylus that I’ve only used to demo Adobe Sketch; the keyboard has all the programming bracket keys, but oddly spaced; the case is a nice compromise between cheap, sturdy, and thin; the battery life lets me forget about the machine for a few days.

    Messing Around

    Google says that you can run Android apps on Chrome OS, but that might be stretching the truth a little. Chrome OS emulates Android for each app. Apps appear on a phone-sized rectangle, with a buggy option to resize to the entire screen. The file access seems to be limited to files under the app’s install directory, so text-editor output might not be useful and there’s no access to the SD-card from Android, presenting a hurdle for playing music stored locally.

    I tried without success to get several Android music players to work. To make matters more confusing, VLC has two versions that appear identical in the application tray — one for Android and one for Chrome OS. The former is buggy and freezes. The latter is a Chrome app…. which Google won’t support outside Chrome OS, so I worry VLC’s future. Google Play Music no longer lets you play music from an SD card. In the end, I found that Remo works reliably, but exposes a track ordering and song selection identical to the filesystem.

    I’m not so in love with my favorite Android apps, kWS and Jota, that I’ve unlocked Chrome OS beyond installing local Chrome Extensions.

    Accessing a Server

    The easiest way to get my code fix via Chrome OS is just to install an ssh Chrome extension and connect to my server. There are several similar extensions. I just chose the one recommended from the crosh shell. Programming via an ssh connection reminds me of VT-100 and modem wails in college, but out of the box I got the same syntax highlighting from vim, YouCompleteMe, and npx. mdv piped into less -R pretty prints markdown well enough.

    Untethered Development

    For proof of concept that one could write something using only a ChromeBook, I used Text to write a simple hello-world Chrome Extension from Google’s tutorial. Presumably one could work in the emulated Android environment with Termux, suggested on Medium….