Sublime Text: “ImportError: No module named sublimeplugin” i.e. bad plugin documentation

TLDR: Sublime Text’s plugin Examples page is out of date as of 30th May 2014. Look at “How to Create a Sublime Text 2 Plugin” for proper guidance.

For the popularity that Sublime Text gets, it seems that their plugin documentation has been left by the wayside

Their Plugin Examples page is out of date showing an example for SublimeText 1. I found that out when creating the plugin only to see the following error message in the Sublime Text console (Ctrl+~ in Windows)

ImportError: No module named sublimeplugin

Searching for this error I landed on this forum post which the link to “How to Create a Sublime Text 2 Plugin” from Tuts+ which seems to work.

There seems to be a change from camelCase to snake_case for functions thus all the instructions on the plugin page are incorrect.

Links API References: choose appropriate link for Sublime Text version

Advertisements

What happened to the WordPress I used to know?

So it’s been a long time since I’ve blogged and this is the first time I’m using the new snazzy WordPress posting process on the website which seems to have been Tumblr-ised

Tumblr’s posting pageImage

WordPress.com’s posting pageImage

But aside from that I started composing a new post and did a preview which didn’t look right at all

Image

I first thought the preview was broken due to some weird HTML, so I looked for the “View source/HTML” option and I couldn’t find it!

Clicked the help and it stated that I could turn it off in my “Your Profile” submenu.

Image

Guess what? I couldn’t find this “Your Profile” submenu

Image

Thought the logical place it would be is in “Personal Settings” or editing my profile but still not there. Clicking the edit link on the preview window brought me back to the new posting page with my full post, and clicking preview still did nothing. It was still loading an old version of the post.

Luckily I tried editing the post via the admin interface and was greeted with the editor I was familiar with and provided the functionality that I love.

Image

Image

This hits another annoyance that I have with so called “upgrades” that remove features. This things will hopefully get logged on #upgradeIsADowngrade

Broken PhoneGap 3.0.0 Installation and Documentation

// TLDR – start

  • Phonegap 3.0.0 documentation is broken.
  • Download the project template
  • replace your www folder with that in the project template
  • Use “phonegap local build ios”
  • Xcode project files in platforms/ios/HelloWorld.xcodeproj

// TLDR – end

So I go to install Phonegap for while playing around with developing on iOS and find that they have yet again changed their process of installation and setting up projects. While that annoys me somewhat, what really annoys me is that the installation and documentation is broken.

Firstly the following command from the documentation (http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface)

$ phonegap create hello com.example.hello HelloWorld

Gives me an error

[error] downloaded www assets in /Users/thewheat/.cordova/lib/www/phonegap/3.0.0/www does not contain index.html, or www subdir with index.html

and it just created a few empty folders

$ ls hello/*
hello/merges:

hello/platforms:

hello/plugins:

hello/www:

Thinking it was just some weird error, I just continued on to the iOS documentation (http://docs.phonegap.com/en/edge/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide_open_a_project_in_the_sdk)

$ cordova create hello com.example.hello "HelloWorld"
$ cd hello
$ cordova platform add ios
$ cordova prepare              # or "cordova build"

This still references “cordova” which was the name of the utility in the previous version before they renamed it to “phonegap”. I changed into the directory and ran the next command which gave the following error

$ cordova platform add ios
-bash: cordova: command not found

Changing it to “phonegap” doesn’t work either

$ phonegap platform add ios
[error] 'platform add ios' is not a phonegap command. See 'phonegap help'

But at least it gave some instruction on what to do. Following that I figured I has to run

$ phonegap local build ios

But alas, more errors

[phonegap] adding the iOS platform...
fs.js:413
 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
 ^
Error: ENOENT, no such file or directory '/Users/thewheat/Dropbox/projects/ios/hello/www/config.xml'
 at Object.fs.openSync (fs.js:413:18)
 at Object.fs.readFileSync (fs.js:270:15)
 at Object.config_parser (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/config_parser.js:24:45)
 at Object.platform (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/platform.js:64:15)
 at LocalBuildCommand.module.exports.addPlatform (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:153:13)
 at LocalBuildCommand.execute (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:95:32)
 at LocalBuildCommand.run (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:70:10)
 at Object.build (/usr/local/lib/node_modules/phonegap/lib/phonegap/util/command.js:28:25)
 at CLI.module.exports (/usr/local/lib/node_modules/phonegap/lib/cli/local.build.js:34:20)
 at CLI.module.exports [as argv] (/usr/local/lib/node_modules/phonegap/lib/cli/argv.js:66:17)

I figured, that I had to manually download the template project structure  (https://codeload.github.com/phonegap/phonegap-app-hello-world/tar.gz/3.0.0), extract it, and replace my project’s “www” folder with that in the template.

$ rm -rf www
$ cp -r ~/Downloads/phonegap-app-hello-world-3.0.0/www .

And now finally it compiles!

$ phonegap local build ios
[phonegap] adding the iOS platform...
[phonegap] compiling iOS...
[phonegap] successfully compiled iOS app

And to open it up in Xcode and finally run the app

$ open platforms/ios/HelloWorld.xcodeproj

Perhaps the node install was corrupted due to something on my computer? But broken documentation such as this really annoys me: a person trying to learn a new tool / library wants to test and play around with it, not debug broken installation guidelines.

(On a sidenote: at least there are some guidelines, there are projects that I’ve seen that don’t give a ‘quick start’ example and assumes you know how to use the tool, which is another peeve of mine)