Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 837547 of Installation

  • Revision slug: Mozilla/Add-ons/SDK/Tutorials/Installation
  • Revision title: Installation
  • Revision id: 837547
  • Created:
  • Creator: willnwhite
  • Is current revision? No
  • Comment

Revision Content

This cfx installation has been deprecated, jpm should now be used instead.

For more information see JPM replaces CFX for Firefox 38.

Prerequisites

To develop add-ons using the current Add-on SDK, you'll need:

  • Python 2.5, 2.6 or 2.7. Note that versions 3.x of Python are not supported on any platform. Make sure that Python is in your path.
  • Firefox.
  • The SDK itself: you can obtain the latest stable version of the SDK as a tarball or a zip file.

Work is under way on a native JavaScript SDK (lookin' at you, Nightlies).

Installation

Installation on OS X, FreeBSD, Linux

Extract the file contents wherever you choose, and navigate to the root directory of the SDK with a shell/command prompt. For example:

tar -xf addon-sdk.tar.gz
cd addon-sdk

Then, if you're a Bash user, run:

source bin/activate

 If you're a non-Bash user, you should run:

bash bin/activate

Your command prompt should now have a new prefix containing the name of the SDK's root directory:

(addon-sdk)~/mozilla/addon-sdk >

The activate command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type activate again. If you want permanent activation, see Making activate permanent below.

Installation on OS X using Homebrew

If you're a Mac user, you can instead choose to use Homebrew to install the SDK, using the following command:

brew install mozilla-addon-sdk

Once this has completed successfully, you can use the cfx program at your command line at any time: you don't need to run bin/activate.

Installation on Windows

Extract the file contents wherever you choose, and navigate to the root directory of the SDK with a shell/command prompt. For example:

7z.exe x addon-sdk.zip
cd addon-sdk

Then run:

bin\activate

Your command prompt should now have a new prefix containing the full path to the SDK's root directory:

(C:\Users\mozilla\sdk\addon-sdk) C:\Users\Work\sdk\addon-sdk>

The activate command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type activate again. If you want permanent activation, see Making activate permanent below.

Sanity check

Run this at your shell prompt:

cfx

It should produce output whose first line looks something like this, followed by many lines of usage information:

Usage: cfx [options] [command]

This is the cfx command-line program. It's your primary interface to the Add-on SDK. You use it to launch Firefox and test your add-on, package your add-on for distribution, view documentation, and run unit tests.

If you don't see this, try the Troubleshooting page.

Next Steps

Next, take a look at the Getting Started With cfx tutorial, which explains how to create add-ons using the cfx tool.

Advanced topics

Using the SDK from Git

The SDK is developed in GitHub. Rather than use the zipped releases, you can check it out from GitHub repository: with this you can use the latest development version rather than an official release.

If you use the latest development version, you must use it with the Nightly version of Firefox, and you won't be able to submit any add-ons you develop to addons.mozilla.org (AMO), because AMO requires that you use an official release.

Building add-ons for AMO from Git

If you do want to build add-ons for submission to AMO using the Git checkout, then you must:

  • use the latest git release tag of the addon-sdk sources
  • run the git archive command to expand some git attribute placeholders in a git clone working directory
git checkout 1.17

git archive 1.17 python-lib/cuddlefish/_version.py | tar -xvf -

Making activate permanent

The activate command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type activate again.

This means that you can have multiple copies of the SDK in different locations on disk and switch between them, or even have them both activated in different command prompts at the same time.

By setting these variables permanently in your environment so every new command prompt reads them, you can make activation permanent. Then you don't need to type activate every time you open up a new command prompt.

Because the exact set of variables may change with new releases of the SDK, it's best to refer to the activation scripts to determine which variables need to be set. Activation uses different scripts and sets different variables for bash environments (Linux and OS X) and for Windows environments.

Windows

On Windows, bin\activate uses activate.bat, and you can make activation permanent using the command line setx tool or the Control Panel.

Steps for settings permanent:

Step 0. Open Control Panel > System > Advanced > Environment Variables.
Step 1. Add the Python directory and your SDK\bin directory to the Path System Variable.
Path=...;C:\PYTHON26\;C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15\bin
Step 2. Add a User variable called CUDDLEFISH_ROOT and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15"
Step 3. Add a User variable called PYTHONPATH and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15\python-lib"
Step 4. Add a User variable called VIRTUAL_ENV and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15"

Linux / OS X

On Linux and OS X, source bin/activate uses the activate bash script, and you can make activation permanent using your ~/.bashrc (on Linux) or ~/.bashprofile (on OS X). In order to do that, open the file:

sudo gedit ~/.bashrc

And add it the following lines at the end of its content:

#making variables of Firefox addon SDK permanent
cd $HOME/DevTools/addon-sdk-1.17/
source ./bin/activate

Then reload the barshrc file:

source ~/.bashrc

As an alternative to this, you can create a symbolic link to the cfx program in your ~/bin directory:

ln -s PATH_TO_SDK/bin/cfx ~/bin/cfx

If you used Homebrew to install the SDK, the environment variables are already set permanently for you.

Revision Source

<div class="warning">
<p><strong>This</strong><strong> <code>cfx</code> installation has been deprecated, <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a> should now be used instead.</strong></p>

<p>For more information see <a href="https://blog.mozilla.org/addons/2015/02/26/jpm-replaces-cfx-for-firefox-38/">JPM replaces CFX for Firefox 38</a>.</p>
</div>

<h2>Prerequisites</h2>

<p>To develop add-ons using the current Add-on SDK, you'll need:</p>

<ul>
 <li><a href="https://www.python.org/">Python</a> 2.5, 2.6 or 2.7. Note that versions 3.x of Python are not supported on any platform. Make sure that Python is in your path.</li>
 <li>Firefox.</li>
 <li>The SDK itself: you can obtain the latest stable version of the SDK as a <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz">tarball</a> or a <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.zip">zip file</a>.</li>
</ul>

<p>Work is under way on a <a href="https://www.npmjs.com/package/jpm">native JavaScript SDK</a>&nbsp;(lookin' at you, Nightlies).</p>

<h2 id="Installation">Installation</h2>

<h3 id="Installation_on_OS_X_FreeBSD_Linux">Installation on OS X, FreeBSD, Linux</h3>

<p>Extract the file contents wherever you choose, and navigate to the root directory of the SDK with a shell/command prompt. For example:</p>

<pre>
tar -xf addon-sdk.tar.gz
cd addon-sdk
</pre>

<p>Then, if you're a Bash user, run:</p>

<pre>
source bin/activate
</pre>

<p>&nbsp;If you're a non-Bash user, you should run:</p>

<pre>
bash bin/activate
</pre>

<p>Your command prompt should now have a new prefix containing the name of the SDK's root directory:</p>

<pre>
(addon-sdk)~/mozilla/addon-sdk &gt;
</pre>

<p>The <code>activate</code> command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type <code>activate</code> again. If you want permanent activation, see <a href="/en-US/Add-ons/SDK/Tutorials/Installation#Making_activate_permanent">Making activate permanent</a> below.</p>

<h3 id="Installation_on_OS_X_using_Homebrew">Installation on OS X using Homebrew</h3>

<p>If you're a Mac user, you can instead choose to use <a href="https://brew.sh/">Homebrew</a> to install the SDK, using the following command:</p>

<pre>
brew install mozilla-addon-sdk</pre>

<p>Once this has completed successfully, you can use the <code>cfx</code> program at your command line at any time: you don't need to run bin/activate.</p>

<h3 id="Installation_on_Windows">Installation on Windows</h3>

<p>Extract the file contents wherever you choose, and navigate to the root directory of the SDK with a shell/command prompt. For example:</p>

<pre>
7z.exe x addon-sdk.zip
cd addon-sdk
</pre>

<p>Then run:</p>

<pre>
bin\activate
</pre>

<p>Your command prompt should now have a new prefix containing the full path to the SDK's root directory:</p>

<pre>
(C:\Users\mozilla\sdk\addon-sdk) C:\Users\Work\sdk\addon-sdk&gt;
</pre>

<p>The <code>activate</code> command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type <code>activate</code> again. If you want permanent activation, see <a href="/en-US/Add-ons/SDK/Tutorials/Installation#Making_activate_permanent">Making activate permanent</a> below.</p>

<h2 id="Sanity_check">Sanity check</h2>

<p>Run this at your shell prompt:</p>

<pre class="language-html" data-number="">
<code class="language-html">cfx</code></pre>

<p>It should produce output whose first line looks something like this, followed by many lines of usage information:</p>

<pre class="language-html" data-number="">
Usage: cfx [options] [command]</pre>

<p>This is the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/cfx"><code>cfx</code> command-line program</a>. It's your primary interface to the Add-on SDK. You use it to launch Firefox and test your add-on, package your add-on for distribution, view documentation, and run unit tests.</p>

<p>If you don't see this, try the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Troubleshooting">Troubleshooting</a> page.</p>

<h2 id="Next_Steps">Next Steps</h2>

<p>Next, take a look at the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_With_cfx">Getting Started With cfx</a> tutorial, which explains how to create add-ons using the <code>cfx</code> tool.</p>

<h2 id="Advanced_topics">Advanced topics</h2>

<h3 id="Using_the_SDK_from_Git">Using the SDK from Git</h3>

<p>The SDK is developed in GitHub. Rather than use the zipped releases, you can check it out from <a href="https://github.com/mozilla/addon-sdk">GitHub repository</a>: with this you can use the latest development version rather than an official release.</p>

<p>If you use the latest development version, you must use it with the Nightly version of Firefox, and you won't be able to submit any add-ons you develop to <a href="https://addons.mozilla.org/">addons.mozilla.org</a> (AMO), because AMO requires that you use an official release.</p>

<h4 id="Building_add-ons_for_AMO_from_Git">Building add-ons for AMO from Git</h4>

<p>If you do want to build add-ons for submission to AMO using the Git checkout, then you must:</p>

<ul>
 <li>use the latest git release tag of the addon-sdk sources</li>
 <li>run the <code>git archive</code> command to expand some git attribute placeholders in a git clone working directory</li>
</ul>

<pre>
git checkout 1.17

git archive 1.17 python-lib/cuddlefish/_version.py | tar -xvf -</pre>

<h3 id="Making_activate_permanent">Making <code>activate</code> permanent</h3>

<p>The <code>activate</code> command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type <code>activate</code> again.</p>

<p>This means that you can have multiple copies of the SDK in different locations on disk and switch between them, or even have them both activated in different command prompts at the same time.</p>

<p>By setting these variables permanently in your environment so every new command prompt reads them, you can make activation permanent. Then you don't need to type <code>activate</code> every time you open up a new command prompt.</p>

<p>Because the exact set of variables may change with new releases of the SDK, it's best to refer to the activation scripts to determine which variables need to be set. Activation uses different scripts and sets different variables for bash environments (Linux and OS X) and for Windows environments.</p>

<h4 id="Windows">Windows</h4>

<p>On Windows, <code>bin\activate</code> uses <code>activate.bat</code>, and you can make activation permanent using the command line <code>setx</code> tool or the Control Panel.</p>

<p><strong>Steps for settings permanent:</strong></p>

<p style="margin-left: 40px;">Step 0. Open Control Panel &gt; System &gt; Advanced &gt; Environment Variables.<br />
 Step 1. Add the Python directory and your SDK\bin directory to the Path System Variable.<br />
 Path=...;C:\PYTHON26\;C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15\bin<br />
 Step 2. Add a User variable called CUDDLEFISH_ROOT and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15"<br />
 Step 3. Add a User variable called PYTHONPATH and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15\python-lib"<br />
 Step 4. Add a User variable called VIRTUAL_ENV and set its value to "C:\Users\Omid\Documents\FirefoxAddons\addon-sdk-1.15"</p>

<h4 id="Linux_OS_X">Linux / OS X</h4>

<p>On Linux and OS X, <code>source bin/activate</code> uses the <code>activate</code> bash script, and you can make activation permanent using your <code>~/.bashrc</code> (on Linux) or <code>~/.bashprofile</code> (on OS X). In order to do that, open the file:</p>

<pre>
sudo gedit ~/.bashrc</pre>

<p>And add it the following lines at the end of its content:</p>

<pre>
#making variables of Firefox addon SDK permanent
cd $HOME/DevTools/addon-sdk-1.17/
source ./bin/activate</pre>

<p>Then reload the barshrc file:</p>

<pre>
source ~/.bashrc</pre>

<p>As an alternative to this, you can create a symbolic link to the <code>cfx</code> program in your <code>~/bin</code> directory:</p>

<pre>
ln -s PATH_TO_SDK/bin/cfx ~/bin/cfx
</pre>

<p>If you used Homebrew to install the SDK, the environment variables are already set permanently for you.</p>
Revert to this revision