Showing posts with label WIndows. Show all posts
Showing posts with label WIndows. Show all posts

7.8.12

Ruby on Rails GemNotFound / FetchError / connection attempt failed!

I didn't post for a very long time!
I had alot of sketches though but didn't had the time to finish and publish them..

But i hope to come back now with more posts!
Also i'm gonna stick to a new format in my posts thati think is better to read. maybe i'll also update old posts to this format.

I just started learning Ruby on Rails few weeks ago and ran into a very weird problem.

Environment:


I'm using Windows 7 64bit with RubyMine 4.5.1, Ruby 1.9.3, Rails 3.2.

I was able to install all this working environment on my Desktop but not on my Laptop..


Problem:


I encounterd the following errors on cmd & RubyMine:
C:\Users\Danpe>gem install rails
WARNING:  Error fetching data: Errno::ECONNREFUSED: No connection could be made
because the target machine actively refused it. - connect(2) (http://rubygems.org/latest_specs.4.8.gz) 
`block in materialize': Could not find rake-0.9.2.2 in any of the sources (Bundler::GemNotFound)

Fetching source index for `http://rubygems.org/`  Could not reach rubygems repository `http://rubygems.org/`  Could not find gem 'rspec-rails (>= 2.0.0.beta.22, runtime)' in any of the gem sources.

 ERROR: http://rubygems.org/ does not appear to be a repository       ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
 Errno::ETIMEDOUT: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed
because connected host has failed to respond. - connect(2)           (http://rubygems.org/yaml)
 I got all these kind of weird errors!

Research:


 so i started looking around the web and around my PC network settings.

I double checked my Internet Options to see that there is no proxy enabled, and there was none!
I opened cmd and typed SET to see my Environment Variables:

C:\Users\Danpe>SET
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Danpe\AppData\Roaming
COMPUTERNAME=DANPE-ZENBOOK
ComSpec=C:\Windows\system32\cmd.exe
HOMEDRIVE=C:
HOMEPATH=\Users\Danpe
HTTP_PROXY=192.168.0.1:8080
 As you can see there is an Environment Variable for HTTP_PROXY...

Solution:


Go to Start (WinKey) type Edit the system environment variables and you'll get this window:


Click on Environment Variables and then remove HTTP_PROXY from System Variables!

Make sure you reopen cmd and RubyMine :)

28.6.11

Run application on Windows Startup

Hey,

In this post i'm gonna show you how to run an application on Windows Startup by adding the application to the registry in the right place.

First of all add this using:
using Microsoft.Win32;

So we can accesss the Registry of the computer.
Define a RegistryKey:

// The path to the key where Windows looks for startup applications
RegistryKey rkApp=Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);

You can change the CurrentUser to LocalMachine if you want your application to run on startup for all users.

Create the registry key and close the registry key handler:

rkApp.SetValue("notepad", @"C:\WINDOWS\system32\notepad.exe"); // Make notepad run on startup                 
rkApp.Close(); //Close the RegistryKey handler
Now notepad will always run when you turn on your PC :P


Nice registry locations can be found here: Registry Autostart Locations

Have fun tweaking the registry :)